- The VM does not handle fragmentation in the memory. This means that allocating and de-allocating a large number of small sized memory chunks might lead to the situation where a memory request will not be honored because of the lack of a contiguous block of suitable size even though the amount of memory is available. Thus it is advisable to allocate larger needed chunks of memory first.
- In general, due to heap fragmentation, it is recommended to add ~40% to the estimated trusted application heap usage from the amount measured in profiling and use that larger value as a manifest parameter.
- For the above reason trying to allocate a large buffer (e.g. for encryption or transmission) may fail while allocating a number of smaller buffers, even with the same total size, may succeed.
- It is recommended to let the garbage collector handle the memory that you are not using, i.e., don’t save, as members of the class, memory that you don’t need to.
- When the applet runs out of memory,OutOfMemoryErrorshould be thrown, to allow the applet to recover properly (i.e., to release unused memory). Note that there are cases whenOutOfMemoryErrorshould be thrown but there is not enough memory to allocate the error. If this happens, the session with the applet is terminated and the host application receives anAPPLET_FATALerror.