浏览代码

[java] Added Gc

Caue Waneck 12 年之前
父节点
当前提交
14b3edc11c
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      std/java/vm/Gc.hx

+ 15 - 0
std/java/vm/Gc.hx

@@ -0,0 +1,15 @@
+package java.vm;
+
+@:native('haxe.java.vm.Gc') class Gc
+{
+	public static function run( major : Bool )
+	{
+		java.lang.System.gc();
+	}
+
+	public static function stats() : { heap : Int, free : Int }
+	{
+		var r = java.lang.Runtime.getRuntime();
+		return { heap : r.totalMemory(), free : r.freeMemory() };
+	}
+}