Estimate for how much RAM used in loading assets.

This commit is contained in:
lieght
2025-10-01 19:30:57 +02:00
parent afdadbba66
commit f86775ff4c

View File

@@ -60,8 +60,23 @@ public class AssetLoader {
List<File> foundFiles = new ArrayList<>(); List<File> foundFiles = new ArrayList<>();
fileSearcher(rootFolder, foundFiles); fileSearcher(rootFolder, foundFiles);
this.totalCount = foundFiles.size(); this.totalCount = foundFiles.size();
// measure memory before loading
long before = getUsedMemory();
loader(foundFiles); loader(foundFiles);
logger.info("Total files loaded: " + this.totalCount);
// ~measure memory after loading
long after = getUsedMemory();
long used = after - before;
logger.info("Total files loaded: {}", this.totalCount);
logger.info("Memory used by assets: ~{} MB", used / (1024 * 1024));
}
private static long getUsedMemory() {
Runtime runtime = Runtime.getRuntime();
return runtime.totalMemory() - runtime.freeMemory();
} }
/** /**