LagFixer
Lightweight and efficient at the same time!
Why LagFixer?
Well, Java creates different Objects all the time. This Objects have a specific sense but after they did their job, they are not needed anymore. Java normally sorts this "not needed" Objects out and removes them from the memory.
Thing is: Java does not automatically remove ALL not needed Objects. Some - although they became useless - stay in the memory of a server. They are most likely removed after some time, but some useless Objects always stay. The amount of useless Objects rises from time to time.
What LagFixer does, is calling the Java Method "System.gc();" after a configurable amount of time. This method makes Java search for all remaining useless Objects in order to delete them. A really effective method especially for Bukkit Servers: Bukkit Servers often run many different Plugins, and all of them create different Objects which lead to a bad performance. That's the reason, why many Bukkit Servers have to restart after some Time: Because else they would crash due to a high amount of useless Objects in memory.
Before I tried the Garbage Collector out, I didn't really believe it would work, because I thought Bukkit itself would handle things like that. I was wrong...
Just try it out yourself! Before and After LagFixer is executed, the current memory is displayed in the Console/Server.log
Features
- Removes unused Objects from the memory
- Executed every x seconds (Configurable amount of time)
- Current memory before and after execution is shown
Commands
- /memory - Shows current Memory
Permissons
- LagFixer.Memory - Permission for the /memory command
Disclaimer
Link to Discussion against gc()
Calling the garbage collector should not be needed, but I've seen so many poorly coded plugins, where I think it actually helps. I personally always had doubts about the garbage collector and possible disadvantages but all my tests worked fine (On servers with 200+ players) and it really increased the performance. Java has an automatic clever garbage collector which should remove all unused objects as soon as a specific amount of objects is reached, however I've seen many servers crashing due to memory issues. LagFixer solved this crashes. Just test this out yourself, it doesn't hurt!
In windows it reports the correct amount of ram, and outputs correctly with both sheduled gc and running the /memory command. But then I uploaded it to a hosted server running linux and it reports incorrectly.
Windows (1gb ram):
[INFO]: Current Memory (Free/Max | Used (%)): 857MB/955MB | 98MB (10%)
Host (6gb ram, Essentials reports 5,333mb):
[INFO] Current Memory (Free/Max | Used (%)): -1915MB/1297MB | 3212MB (247%)
Using 247% of ram capacity is quite an oddity :)
@ch0xy
nope :P It will work fine :)
Do you think this would bring any issues on a 1.6.4 server?
@PrimoHighDefinition
Yep
Is this working with spigot?
@CommodoreAlpha
" I read that relying on calling the garbage collector is an indicator of a fundamentally broken system. In this scenario, what exactly is broken?"
It can be used as an indicator of a fundamentally broken system but LagFixer rather is used to prevent the amount of unused objects from being high, to solve crashes and to prevent the lag caused by poorly coded plugins (This of course won't fix all lags caused by poorly coded plugins)
"If, say, you're running a minimal amount of well-built plugins that are optimised by professional developers, and you're holding 200+ players all the time, would you ever need to manually call the garbage collector?"
If everything is running fine without LagFixer: No.
Otherwise I suggest testing it out. It might be a huge improvement for your server or it might do almost nothing.
So wait, I'm a bit confused. I read that relying on calling the garbage collector is an indicator of a fundamentally broken system. In this scenario, what exactly is broken?
If, say, you're running a minimal amount of well-built plugins that are optimised by professional developers, and you're holding 200+ players all the time, would you ever need to manually call the garbage collector?
If not, then it's pretty clear the "bottleneck" in efficient memory usage is plugins. But if you still need to do a manual call under this circumstance, then wouldn't it be inferred that Bukkit or Minecraft is inherently "broken"? (As I've said, assume there are a minimal amount of plugins that are highly optimised.)
In other news, that article was a very good read. Thanks for pointing me in that direction. :)
@CommodoreAlpha
Just added this disclaimer: http://snapcr.net/c/36fe.png
@CommodoreAlpha
Because this plugin is redundant since Java has automatic garbage collection.
See: http://stackoverflow.com/questions/2414105/why-is-it-a-bad-practice-to-call-system-gc
If it's this useful, then why hasn't been implemented before, or why hasn't a plugin like this one come out a long time ago? (I'm not skeptical of your plugin, but I am curious.)
The uploaded (not approved yet) Version should work forever. The Plugin works fine but won't be updated anymore.
Whats happen with this plugin?
Great idea for a plugin! I look forward to releases!