Here you can find the source of getMemoryStats(int mode)
Parameter | Description |
---|---|
mode | Use RuntimeHelper.XXX_MEMORY (total, used, free) |
public static int getMemoryStats(int mode)
//package com.java2s; /*//w w w . j a v a 2 s. c om * Copyright (c) 2014 mgamelabs * To see our full license terms, please visit https://github.com/mgamelabs/mengine/blob/master/LICENSE.md * All rights reserved. */ public class Main { public static final int TOTAL_MEMORY = 0; public static final int USED_MEMORY = 1; public static final int FREE_MEMORY = 2; private static Runtime runtime; /** * Returns the desired information about the game's memory * * @param mode Use RuntimeHelper.XXX_MEMORY (total, used, free) * @return The desired information */ public static int getMemoryStats(int mode) { switch (mode) { case TOTAL_MEMORY: return (int) (runtime.totalMemory() / 1024 / 1024); case USED_MEMORY: return (int) ((runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024); case FREE_MEMORY: return (int) (runtime.freeMemory() / 1024 / 1024); } return 0; } }