public void dispose() {
        //System.out.println("   Shapes Images vector size " + images.size());
        for (Image image : images) {
            image.flush();
        }
        // one more try to free up some memory
        images.clear();
        images.trimToSize();

        //System.out.println("   Shapes Shapes vector  size " + images.size());
        if (shapes != null){
            for (Object tmp : shapes) {
                if (tmp instanceof Image) {
                    //System.out.println("  -------------> Found images");
                    Image image = (Image) tmp;
                    image.flush();
                } else if (tmp instanceof TextSprite) {
                    ((TextSprite) tmp).dispose();
                }else if (tmp instanceof Shapes) {
                    ((Shapes) tmp).dispose();
                }  else {
                    //System.out.println("  -------------> Found other " + shapes.size());
                    //tmp = null;
                }
            }
            shapes.clear();
            shapes.trimToSize();
            shapes = null;
        }

        if (pageText != null){
            pageText.dispose();
            pageText = null;
        }
    }