One way to deal with this is the following scheme:

Provide an interface for users to supply their own work storage option.
The interface has a "dispose" function, and can be something similar to:

interface ImageStorage {
    void dispose();
    int read(int offset);
    int read();
    void write(byte [] data);
    void write(byte [] data, int offset, int length);
    int read(byte [] data);
    void seek(int offset);
    void setLength(int length);
    int getLength();
    ...
}

Almost like the random access file api.  "int" can be changed to "long" if 
needed (or use generic).

Default implementation (and for backward compatibility) is a wrap of the byte 
array stream.

Another implementation that can be handy for users is a wrap of random input 
output stream.

For temporary images in the library, it can be done this random input/output 
wrapper.  The dispose function is then called to clean the file.  The file can 
be temporary file (see java.io.File api), and the file can also be set to be 
deleted when garbage collects it (if it's not disposed off properly).

I think this is sufficient because if users provide the storage, they have to 
clean it up.  Each image when created can have this as a parameter.  The scheme 
can be done using something like file resource where you can use try.. finally 
to clean up resource.

If no work storage is provided, 

> Paulo wrote:

Date: Wed, 14 Mar 2007 00:40:43 -0000
From: "Paulo Soares" <[EMAIL PROTECTED]>
Subject: Re: [iText-questions] Out of Memory with Large Image
To: "Post all your questions about iText here"
    <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
    reply-type=original

This is a problem that sooner or later will have to be addressed. Currently 
the whole image is stored in a byte array that is stored in Image. It's not 
terribly difficult to support a temp file but the big question is when to 
delete it. Web servers may also have problems with temp files. I'll think 
about it this weekend.

Paulo



 
____________________________________________________________________________________
It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to