在JDK8中,直接内存可以单独配置,如果您耗尽了直接内存(例如使用ByteBuffer.allocateDirect()分配的内存),那么JDK将使您的应用程序崩溃,并出现out of direct memory错误。
有没有办法以编程方式检查应用程序中还剩下多少直接内存?
发布于 2015-09-29 04:45:54
您可以使用Runtime访问有关分配给运行程序的JVM的内存的信息。
Runtime runtime = Runtime.getRuntime();
long max = runtime.maxMemory();
long free = runtime.freeMemory();
long total = runtime.totalMemory();https://stackoverflow.com/questions/32831361
复制相似问题