Tips For Success

Having the best tools for document imaging is only half of the equation. Our Tech Tips are designed to provide you with valuable information to help succeed by achieving faster results with RasterMaster SDKs or FlexSnap viewers. New time-saving tips are added monthly - you can receive them through Imaging News or our Tech Tips RSS feed.

Using the Snowbound Finalize Method to clear up memory in Java™

This Tech Tip appeared in Imaging News October 2004.

Java garbage collection will only clear up memory allocated to an object when it determines there is no reference out there for that object. The RasterMaster for Java imaging SDK includes a finalize method that sets all the internal data arrays to null as well as the scroll bar components so the GC can remove it.

Although it isn't mandatory, it is best practice to call the finalize method when an object is no longer needed. However, calling the finalize method does not automatically call the Java GC. If the GC does not run before you decompress another image, then the old data is still in memory along with the new data, and you will have less memory to work with. You should call the finalize method before each decompress and also the Java GC (...

(snowbndobj).finalize();

System.gc();

(snowbndobj.IMG_decompress_bitmap("map.tif",0);

...) to make sure you free up the memory previously used by the Snowbound object.

It is perfectly fine to re-use the snowbound object over and over again. You do not need to call the finalize method unless you are done using the object. The finalize needs to be called since the scroll bars are not properly removed internally in Java when the object is deleted.