ServerSync

ServerSync

48.5k Downloads

Out Of Memory: Log Saving Thread

veDesreveR opened this issue · 14 comments

commented

Serversync Version:
3.6.0 (As Client)
Minecraft Version:
1.12.2
OS:
Windows 10 [Latest]
Parameters used:
-a
-o
-p
Launch command:
java -jar serversync.jar -a=*** -p=38067 -o
(I won't post the IP)

Log from console window:

{SYNC_FILES=6.41544229449907E8, GET_MANAGED_DIRECTORIES=5.603943209287407E8, GET_NUMBER_OF_MANAGED_FILES=3.015641569347344E8, UPDATE_FILE=1.9848806328234773E9, EXIT=9.693692096439888E8}
Exception in thread "Log Saving" Exception in thread "Log Saving" Exception in thread "Log Saving" Exception in thread "Log Saving" Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: GC overhead limit exceeded
java.lang.OutOfMemoryError: Java heap space
Exception in thread "Log Saving" Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: GC overhead limit exceeded
java.lang.OutOfMemoryError: Java heap space
Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Log Saving" Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Log Saving" Exception in thread "Log Saving" Exception in thread "Log Saving" Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
at java.lang.StringCoding$StringEncoder.encode(Unknown Source)
at java.lang.StringCoding.encode(Unknown Source)
at java.lang.StringCoding.encode(Unknown Source)
at java.lang.String.getBytes(Unknown Source)
at com.superzanti.serversync.util.Log$1.run(Log.java:58)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
at java.lang.StringCoding$StringEncoder.encode(Unknown Source)
at java.lang.StringCoding.encode(Unknown Source)
at java.lang.StringCoding.encode(Unknown Source)
at java.lang.String.getBytes(Unknown Source)
at com.superzanti.serversync.util.Log$1.run(Log.java:58)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Log Saving" Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
Exception in thread "Log Saving" java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
[...]

Memory usage when the error message appears: ~17.100 MB

EDIT: Seems like the same problem mentioned in issue #190.

commented

Interesting, do you have a way of finding out what your default memory allocation for java programs is?

This is probably fixable by setting the max memory higher when running the program, e.g. java -Xmx512m -jar ...

commented

It is also worth looking into how the log is being saved, it may be trying to read the whole log rather than streaming it.

commented

My default maximum memory allocation is ~ 4GB
I´ll try to find out how much memory is used for the sync process.

commented

I'm having the same issue, in the end it crashes with Exception in thread "Client processing" java.lang.OutOfMemoryError
I've tried launching with following args:
java -Xms256m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -jar ServerSync.jar -a=127.0.0.1 -p=38067 -o

My config for server side is as follows (default lines skipped):

general {
    B:PUSH_CLIENT_MODS=true
}

rules {
    # # These configs are included, by default configs are not synced
    S:CONFIG_INCLUDE_LIST <
        ../knownkeys.txt
        ../options.txt
        ../optionsof.txt
    >

    # # These directories are included, by default mods and configs are included
    S:DIRECTORY_INCLUDE_LIST <
        config
        defaultconfigs
        resourcepacks
        scripts
        shaderpacks
        ma-chat
        mods
    >

    # # These files are ignored by serversync, list auto updates with mods added to the clientmods directory
    S:FILE_IGNORE_LIST <
        **/*.disabled
        **/serversync-forge-loader-1.1.0.jar
        **/serversync-server.cfg
        **/server-only*
        **/.git/**
        **/.DS_Store
    >
}

and the only change in client config is

rules {
    # # These files are ignored by serversync, add your client mods here to stop serversync deleting them.
    S:FILE_IGNORE_LIST <
        **/serversync-*.jar
        **/serversync-*.cfg
        **/xaero*.txt
    >
}

Same is on server side, it barfs with exceptions until it put it out of it's misery, here's a full log of a server-side run: https://pastebin.com/7daeVGSa

commented

Also, serversync-client.log file is as big as 20mb, which is huge:
serversync-client.log.zip

commented

Seems like Log class is quite overcomplicated, maybe just write to a file in an old-fashioned synchroneous way?.. It's not THAT much of an overhead...

commented

The logging is long overdue for an overhaul, it has not really had any love since the start of this project. Should really not be 20mb, presumably something is logging in a loop or something equally silly.

commented

If you have some time could you try out the latest alpha version 4, curious to see if this is still an issue after all of the various changes in version 4.

Probably is considering that the logging has not really been touched that much.

Experimental releases here: https://github.com/rheimus/ServerSync/releases

commented

I've tried to give some love to the logger, but turns out latest master doesn't work. It compiles, but running java -Xms256m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:+DisableExplicitGC -jar serversync-4.0.0-alpha.1.jar -a=127.0.0.1 -p=38067 -o I get Error: Could not find or load main class 'com.superzanti.serversync.ServerSync'

commented

Sounds like the jar file is missing its manifest pointing to the main class. What are you using to compile?

commented

./gradlew build and IntelliJ Idea's "build" command

commented

Try using the compiled jar with the all postfix.

commented

Awesome, it worked. Anyway, I've submitted a PR, and it seems like logging to both UI and logfile is working. serversync-server-connection-from--127-0-0-1 is empty, though, but I'll look into it tomorrow...

commented

I am going to close this for now as the logger has had significant changes in v4.

Feel free to raise another issue or reopen this one if the problem still exists.