mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-12 04:24:32 +02:00
6.43
-Force garbage collector thread
This commit is contained in:
parent
f944fab1b6
commit
7f11f15455
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.tonikelope</groupId>
|
||||
<artifactId>MegaBasterd</artifactId>
|
||||
<version>6.42</version>
|
||||
<version>6.43</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -50,7 +50,7 @@ import javax.swing.UIManager;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "6.42";
|
||||
public static final String VERSION = "6.43";
|
||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
||||
public static final int STREAMER_PORT = 1337;
|
||||
@ -183,6 +183,7 @@ public final class MainPanel {
|
||||
private boolean _megacrypter_reverse;
|
||||
private float _zoom_factor;
|
||||
private volatile boolean _exit;
|
||||
private volatile boolean _forcing_gc;
|
||||
|
||||
public MainPanel() {
|
||||
|
||||
@ -376,6 +377,8 @@ public final class MainPanel {
|
||||
|
||||
Runtime instance = Runtime.getRuntime();
|
||||
|
||||
_forcing_gc = false;
|
||||
|
||||
while (true) {
|
||||
|
||||
long used_memory = instance.totalMemory() - instance.freeMemory();
|
||||
@ -392,19 +395,49 @@ public final class MainPanel {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
Logger.getLogger(MainPanelView.class.getName()).log(Level.INFO, "Forcing garbage collection...");
|
||||
} else {
|
||||
|
||||
swingInvoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
_view.getMemory_status().setText("---------");
|
||||
_view.getMemory_status().setText("(!) " + MiscTools.formatBytes(used_memory) + " / " + MiscTools.formatBytes(max_memory));
|
||||
}
|
||||
});
|
||||
|
||||
if (!_forcing_gc) {
|
||||
|
||||
_forcing_gc = true;
|
||||
|
||||
THREAD_POOL.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
long used_memory = instance.totalMemory() - instance.freeMemory();
|
||||
|
||||
long max_memory = instance.maxMemory();
|
||||
|
||||
while (used_memory >= ((double) max_memory) * 0.7) {
|
||||
|
||||
Logger.getLogger(MainPanelView.class.getName()).log(Level.INFO, "Forcing garbage collection...");
|
||||
|
||||
MiscTools.force_garbage_collection();
|
||||
|
||||
try {
|
||||
Thread.sleep(15000);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(MainPanelView.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
used_memory = instance.totalMemory() - instance.freeMemory();
|
||||
|
||||
max_memory = instance.maxMemory();
|
||||
}
|
||||
|
||||
_forcing_gc = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 204 KiB |
Loading…
x
Reference in New Issue
Block a user