-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(process-file): log low memory availability
- Loading branch information
Showing
5 changed files
with
32 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
16 changes: 16 additions & 0 deletions
16
dossierfacile-process-file/src/main/java/fr/dossierfacile/process/file/util/MemoryUtils.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,16 @@ | ||
package fr.dossierfacile.process.file.util; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class MemoryUtils { | ||
// TODO currently we only log low availability | ||
public static boolean hasEnoughAvailableMemory() { | ||
Runtime runtime = Runtime.getRuntime(); | ||
// Arbitrary choose 250MB as minimal requirement to perform | ||
if (runtime.maxMemory() - runtime.totalMemory() + runtime.freeMemory() < 262144000) { | ||
log.warn("Memory usage: (Total=" + runtime.totalMemory() / 1024 + " MB , max=" + runtime.maxMemory() / 1024 + " MB , free=" + runtime.freeMemory() / 1024 + " MB , avail=" + (runtime.maxMemory() - runtime.totalMemory() + runtime.freeMemory())); | ||
} | ||
return true; | ||
} | ||
} |
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