NetKernel runs within the Java virtual machine and although many aspects of ROC are abstracted from the underlying platform. Java's memory management is one thing that NetKernel cannot take control of. A consequence of this is that it is possible for 3rd party libraries to cause memory leaks that can eventually cause NetKernel to fail with out-of-memory errors.
It is important to distinguish between leaks and normal high heap usage. Although the core of NetKernel is highly optimised to minimise heap usage, large datasets and some complex libraries may have high memory requirements. You will need to ensure adequate heap to deal with all eventualities. Careful system design with consideration for limiting maximum concurrency with endpoints like the throttle will help.
All of the standard modules supplied by 1060 including main and universe sets are thoroughly tested for leaks and unless explicitly stated as experimental or not production ready, they are known to be leak free.
If you are developing your own libraries that integrate 3rd party or even your own code libraries it is important to properly test to ensure they do not leak. Leaks may occur because of intrinsic limitations of the library or because of errors in the integration into endpoints or representations you may develop.
Leaks usually come about in one of several ways:
Several tools can be used to help you keep an eye on heap usage:
Running the following Groovy script in the scripting playpen will allow you to perform a heap dump from within a running NetKernel instance. (Note this is known to work on a Sun JVM)...
//Really Simple Heap Dumper import com.sun.management.HotSpotDiagnosticMXBean import java.lang.management.ManagementFactory import javax.management.MBeanServer dumpfile="heap.bin" server = ManagementFactory.getPlatformMBeanServer() hotspotMBean = ManagementFactory.newPlatformMXBeanProxy( server, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class ); hotspotMBean.dumpHeap(dumpfile, true) context.createResponseFrom("Heap Dumped to $dumpfile")
It is generally a good idea to clear the representation cache before attempting to dump the heap to eliminate the noise of the transient state of cached representations.