-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b892b59
commit 0815b42
Showing
6 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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
28 changes: 28 additions & 0 deletions
28
proxy/src/main/java/net/azisaba/simpleProxy/proxy/util/MemoryReserve.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package net.azisaba.simpleProxy.proxy.util; | ||
|
||
import net.azisaba.simpleProxy.proxy.ProxyInstance; | ||
|
||
public class MemoryReserve { | ||
private static byte[] reserve = null; // 5 MB | ||
|
||
public static void reserve() { | ||
if (reserve == null) { | ||
reserve = new byte[1024 * 1024 * 5]; | ||
} | ||
} | ||
|
||
public static void release() { | ||
reserve = null; | ||
} | ||
|
||
public static void tryShutdownGracefully() { | ||
try { | ||
release(); | ||
System.gc(); | ||
ProxyInstance.getInstance().stop(); | ||
System.exit(0); | ||
} catch (Throwable t) { | ||
System.exit(0xc0000001); | ||
} | ||
} | ||
} |
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