How can I request Java garbage collection in the Java Virtual Machine (JVM) in MATLAB 7.3 (R2006b)?
14 views (last 30 days)
Show older comments
I would like to request Java garbage collection in the Java Virtual Machine (JVM) in MATLAB 7.3 (R2006b).
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
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 Comments
More Answers (0)
See Also
Categories
Find more on Java Package Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!