Selfbot icon indicating copy to clipboard operation
Selfbot copied to clipboard

Out of memory error, heap space

Open hlugt opened this issue 6 years ago • 6 comments

Hi, how much memory is required? On raspi2 I get out of memory error on heap size. java -jar JSelfbot.jar [11:31:48] [Info] [Emojis]: Successfully loaded 1 custom emojis! [11:31:48] [Warning] [Todo]: todo.json was not found! This can be ignored if you haven't added any items to your todo list. [11:31:53] [Info] [JDA]: Login Successful! [11:31:54] [Info] [JDASocket]: Connected to WebSocket [11:33:06] [Fatal] [JDASocket]: Encountered an exception: [11:33:06] [Fatal] [JDASocket]: java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:3332) at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124) at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:649) at java.lang.StringBuilder.append(StringBuilder.java:202) at java.util.regex.Matcher.appendReplacement(Matcher.java:883) at java.util.regex.Matcher.replaceAll(Matcher.java:955) at java.lang.String.replace(String.java:2240) at net.dv8tion.jda.core.utils.SimpleLog.log(SimpleLog.java:311) at net.dv8tion.jda.core.utils.SimpleLog.trace(SimpleLog.java:340) at net.dv8tion.jda.core.requests.WebSocketClient.handleEvent(WebSocketClient.java:940) at net.dv8tion.jda.core.requests.WebSocketClient.onTextMessage(WebSocketClient.java:661) at net.dv8tion.jda.core.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:1001) at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:368) at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:270) at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:990) at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:749) at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108) at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64) at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

hlugt avatar Oct 27 '17 09:10 hlugt

I have the same issue.

BonusHoovy avatar Nov 04 '17 11:11 BonusHoovy

The amount of memory required depends on how many servers you are on, and how many members are on those servers. Consider leaving servers that you don't actively participate in, as all of those are still required to be loaded for the selfbot. Also, you can use the -Xms flag when starting the bot to allocate more memory for the jvm to use (you can google how to do that)

jagrosh avatar Nov 04 '17 15:11 jagrosh

On my windows machine java -jar JSelfBot -Xms:64m gets me a succesfull login. On any linux server I try it fails. Even with -Xms:2g? NB: And even -Xmx:64m works on windows.

hlugt avatar Nov 04 '17 16:11 hlugt

Don't use the colon (:), just use -Xms128M (or whatever value is close to the capacity of your server) and keep in mind that it's just setting the minimum for the jvm to use. If you are on more servers than the linux machine can handle, it won't be able to load no matter what you do.

jagrosh avatar Nov 04 '17 16:11 jagrosh

Hi, thanks jagrosh for your replies. Yes, it seems not to matter using the colon or not. And to limit max usage is why I also set the max -Xmx64m on windows, to try (..) to make sure it does not use more. But it seems it is using memory out of the heap: on windows I see 2GB used by the java proces. And it might run into a limit and fail on that instead. Although I would expect on linux it would start using swap and not fail.

hlugt avatar Nov 05 '17 09:11 hlugt

Ok, tried with different account that is in 2 guilds instead of 68 and then I can connect succesfull. So it is indeed a memory error. I will try to see if I can find a way to allocate memory in a way that the selfbot does not crash...

hlugt avatar Nov 05 '17 10:11 hlugt