How can I request Java garbage collection in the Java Virtual Machine (JVM) in MATLAB 7.3 (R2006b)?

14 次查看(过去 30 天)

采纳的回答

MathWorks Support Team
While it is not possible to force the Java VM to release memory of de-referenced objects, you can request that the JVM performs garbage collection. This may result in the desired memory being released. Issue the following command from the MATLAB command prompt:
java.lang.System.gc()
Another method to request Java garbage collection is to create a Java Runtime object and call its 'gc' method. This can be done at the MATLAB command prompt with:
java.lang.Runtime.getRuntime().gc
Garbage collection is run as separate thread in the JVM. The garbage collector (GC) runs as Java priority 1 (the lowest priority). The virtual machine, VM, runs at Java priority 10 (the highest priority). In most cases, the GC runs during idle times, generally when the VM is waiting for user input or when available memory is low. In the latter case, the GC interrupts high-priority processing in the application in order to free memory.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Java Package Integration 的更多信息

产品


版本

R2006b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by