Created
November 1, 2012 20:24
-
-
Save jnorthrup/3996244 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* might avoid growing heap, swapping heap, etc. and likely to constantly trigger gc in gwtc. | |
*/ | |
static { | |
String wantHeadroom = System.getProperty("wantHeadroom",""); | |
if(!wantHeadroom.isEmpty()) | |
new Timer().scheduleAtFixedRate(new TimerTask() { | |
private Runtime runtime = Runtime.getRuntime(); | |
@Override | |
public void run() { | |
long l = runtime.freeMemory(); | |
long l1 = runtime.totalMemory(); | |
if(.2f*l1>l) | |
System.gc(); | |
} | |
}, 1000,1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment