public void dispose(boolean cache) { /* System.out.println("Resources.dispose() cache: " + cache); try { throw new RuntimeException("MARK"); } catch(Exception e) { StackTraceElement[] ste = e.getStackTrace(); for(int i = 1; i < Math.min(20,ste.length); i++) System.out.println(" " + ste[i].getClassName() + "." + ste[i].getMethodName() + " : " + ste[i].getLineNumber()); } */ // remove all images. if (images != null) { Enumeration shapeContent = images.elements(); // find all shapes that are images while (shapeContent.hasMoreElements()) { Object image = shapeContent.nextElement(); if (image instanceof Bitmap) { Bitmap tmp = (Bitmap) image; tmp.recycle(); } } // clear hash to free max memory images.clear(); } // NOTE: Make sure not to clear fonts, color spaces, pattern, // or extGStat's as this hold reverences to object not the actual // object. The only images contain object with a lot of memory if (xobjects != null) { Enumeration xobjectContent = xobjects.elements(); while (xobjectContent.hasMoreElements()) { Object tmp = xobjectContent.nextElement(); if (tmp instanceof Stream) { Stream stream = (Stream) tmp; stream.dispose(cache); } if (tmp instanceof Reference) { Object reference = library.getObject((Reference) tmp); if (reference instanceof Form) { Form form = (Form) reference; form.dispose(cache); } if (reference instanceof Stream) { Stream stream = (Stream) reference; stream.dispose(cache); } } } } }