Skip to content

Commit

Permalink
memory logger
Browse files Browse the repository at this point in the history
  • Loading branch information
kafuuchino-desu committed Oct 7, 2019
1 parent d61ec80 commit e2bb34d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/carpet/logging/LoggerRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class LoggerRegistry
public static boolean __pathfinding;
public static boolean __chunkdebug;
public static boolean __villagecount;
public static boolean __memory;

public static void initLoggers()
{
Expand All @@ -51,6 +52,9 @@ public static void initLoggers()

//TISCM: add villagecount
registerLogger("villagecount", new HUDLogger("villagecount", null, null));

//TISCM: add memory
registerLogger("memory", new HUDLogger("memory", null, null));
}

/**
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/carpet/utils/HUDController.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public static void update_hud(MinecraftServer server)
if (LoggerRegistry.__villagecount)
LoggerRegistry.getLogger("villagecount").log(() -> send_total_villages(server));

if (LoggerRegistry.__memory)
LoggerRegistry.getLogger("memory").log(() -> send_mem_usage());

for (EntityPlayer player: player_huds.keySet())
{
SPacketPlayerListHeaderFooter packet = new SPacketPlayerListHeaderFooter();
Expand Down Expand Up @@ -146,4 +149,14 @@ public static void update_hud(MinecraftServer server)
};
return ret;
}

private static ITextComponent [] send_mem_usage()
{


ITextComponent [] ret = new ITextComponent[]{
Messenger.c("g "+ (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory())/1048576 + "M / " +(Runtime.getRuntime().maxMemory()/1048576) + " M"),
};
return ret;
}
}

0 comments on commit e2bb34d

Please sign in to comment.