Project: datamanagement
Issue DM-4245: Image Viewer memory leak
When reloading the same 500MB RAFT image into an image viewer (see the script below), it was discovered that single node Firefy server with 3G memory runs out of memory after ~15 reloads Test case: keep reloading the html file with the following Javascript, creating an image viewer with 500MB image: function onFireflyLoaded() { var iv2= firefly.makeImageViewer("plot"); iv2.plot({ "Title" :"Example FITS Image'", "ColorTable" :"16", "RangeValues":firefly.serializeRangeValues("Sigma",-2,8,"Linear"), "URL" :"http://localhost/demo/E000_RAFT_R01.fits"}); } Follow up: The bug was traced to java.awt.image.BufferedImage objects not being evicted from VIS_SHARED_MEM cache. Further search showed that java.awt.image.BufferedImage (along with java.io.BufferedInputStream) is in src/firefly/java/edu/caltech/ipac/firefly/server/cache/resources/ignore_sizeof.txt, which lists the classes that have to be ignored when calculating the size of cache. Testing on single node server (VIS_SHARED_MEM cache is not replicated), using [host:port]/fftools/admin/status page: BEFORE (java.awt.image.BufferedImage was commented out in ignore_sizeof.txt) After 14 reloads: Memory - Used : 3.7G - Max : 3.55G - Max Free : 488.0M - Free Active : 488.0M - Total Active : 3.55G Caches:	VIS_SHARED_MEM @327294449	Statistics : [ Size:15 Expired:0 Evicted:0 Hits:246 Hit-Ratio:NaN Heap-Size:1120MB ] OUT OF MEMORY on next reload AFTER THE CHANGE (Commented java.awt.image.BufferedImage in ignore_sizeof.txt) After 36 reloads: Memory - Used : 1672.9M - Max : 3.55G - Max Free : 1968.0M - Free Active : 1468.0M - Total Active : 3.6G Caches:	VIS_SHARED_MEM @201164543	Statistics : [ Size:3 Expired:0 Evicted:34 Hits:659 Hit-Ratio:NaN Heap-Size:1398MB ]
Story points: 2