Various Utility Functions
Memory Functions
Mathematica does unfortunately not release unused memory back to the operating system, this is the case on all platforms. A simple example shows the problem.
We test this as follows:
a) start with a fresh kernel
b) measure the memory consumption of Mathematica
c) look at the memory consuption of Mathematica from the operating system (on Windows: Task Manager (Processes tab, look for the MathKernel process), on Linux/Solaris/Unix: top)
d) assign a large data structure to a variable
e) do steps b) and c) again
f) Clear[] or Remove[] that variable
g) do steps b) and c) again.
We find that Mathematica did not release the memory back to the operating system, although the variable has been cleared/removed:
For this test, which was run on Linux, the values for %MEM, VIRT, RES, and SHR for the process MathKernel were 0.6, 676m, 31m, and 7616 after step 1. After step 3 the values were 24.7, 1748m, 785m, and 7628. After step 5 the values were 25.8, 1748m, 785m, and 7628, showing that Mathematica is hogging the unused memory it no longer needs. However, the same is true for Solaris, Unix, Windows, and Mac, not just on Linux.
This is a problem, as unused memory resources should be released back to the operating system, so that a) other applications can use the memory capacity, and b) larger amounts of memory are more difficult and time-consuming to manage, slowing down the whole system.
Therefore the function JClearMemory[] has been created for JavaTools, which, when called after a Clear[] or Remove[] of a symbol, will ensure the memory is released back to the operating system.
The memory diagnostics from top reflect this, after step 5 they are near the values they had after step 1.
It is important to call JClearMemory[] immediately after the Remove[] or Clear[], or it will not work.
Note that this problem doesn't exist at all for the data that is stored in the data structures provided by JavaTools, which are based on the Google Collections (Guava), as the data is in the Java Virtual Machine where the Java Garbage Collector automatically takes care of memory release for unused variables/arrays.
Various Other Utility Functions
Note that the output of JFormat[] is a String!
Obtain Server Messages / Announcements
This function informs you about recent updates relevant to JavaTools, such as a new Java version or a new Google Guava / Collections version, or an upgraded version of JavaTools itself, or other types of announcements. You are recommended to upgrade to a new Java, Guava, or JavaTools version as soon as it is available, ESPECIALLY when Oracle has also updated the security baseline when updating Java (the most current security baseline is Java 7 update 2.). Feel free to request a new version of JavaTools that is recompiled with the updated version(s) by sending an email containing your name and $MachineID to javatools@lauschkeconsulting.com. You will receive a new version of JavaTools compiled with the updated libraries from Lauschke Consulting within 24 hours.
JavaTools does not connect to the JavaTools server UNLESS you call JGetServerMessages[]. This is the ONLY function that requires you to be connected to the internet. None of your private data or program is ever sent to the server. The only data sent to the JavaTools server is a string encoding of the RSA public key created by this request. The reply from the server is sent to your JavaTools application in 2048 bit strength RSA encryption.