Hello,
In almost every case, the memory (JVM heap) is mostly taken by the tasks executing in a node, rather than by the JPPF node itself. For information, an idle node connected to a server takes as low as 1.6 MB of heap, immediately after a full garbage collection. That is a very small footprint.
There are many ways to obtain or use the available heap of a node. A typical usage is via an
execution policy in the job's SLA, using the available node
runtime information. For example, a policy specifying that a job can only execute on a node with at least 2GB of available heap could be written like this:
JPPFJob job = new JPPFJob();
long GB = 1024L * 1024L * 1024L;
// execute on nodes with at least 2GB
job.getSLA().setExecutionPolicy(new AtLeast("freeMemory", 2 * GB));
You may also use the JMX-based monitoring API, in particular the
JVM diagnostics/health MBean to have an up to date view of the heap and non-heap memory usage, along with other information such as CPU load etc...
If you want your tasks to know the currently available heap, you could use a simple function like this one:
public static long maxFreeHeap() {
Runtime rt = Runtime.getRuntime();
return rt.maxMemory() - (rt.totalMemory() - rt.freeMemory());
}
Sincerely,
-Laurent