我能得到多少内存我的程序仍然? [英] Can I get how much memory for my program remains?
问题描述
我的程序有需要大量的内存,我不能确切地知道,当我需要停止它的许多作品,但万一有离开后,我可以强制停止使用的资源很少的内存。所以,我可以得到多少剩余(字节)的内存,我的程序就可以使用?
My program has many works that need a lot of memory that I can't exactly know when I need to stop it, but in case there's very few memory left, I can force it stop using resources. So can I get how many remaining (in byte) memory that my program can use?
在先进的感谢。
P / S:有没有办法来释放进程内存。他们需要的内存,尽可能的,那就是它是如何工作(并为收藏家没有垃圾,因为旧的仍然需要)。
P/s: There's NO way to release the process memory. They need memory, as much as possible, and that is how it works (and, no trash for collector, since old ones still be need).
推荐答案
尝试是这样的:
Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
Debug.getMemoryInfo(memoryInfo);
String memMessage = String.format("Memory: Pss=%.2f MB,
Private=%.2f MB, Shared=%.2f MB",
memoryInfo.getTotalPss() / 1024.0,
memoryInfo.getTotalPrivateDirty() / 1024.0,
memoryInfo.getTotalSharedDirty() / 1024.0);
您可以阅读更多在这个博客:<一href=\"http://huenlil.pixnet.net/blog/post/26872625\">http://huenlil.pixnet.net/blog/post/26872625
You can read more at this blog: http://huenlil.pixnet.net/blog/post/26872625
这篇关于我能得到多少内存我的程序仍然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!