Free Support Forum - aspose.com

Alternative method for generating thumbnails of Word documents

Hi there

I have a program which uses the sample code provided in the Aspose.Words helpfile to generate thumbnails of each page in a given document. However, it seems that because this code uses System.Drawing.Bitmap objects to represent images, I’m experiencing a problem with excessive memory consumption by these objects. Is there an alternative way to generate thumbnails that doesnt use System.Drawing.Bitmap objects?

Thanks

Eric






Hi Eric,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Have you tried disposing bitmap objects? After disposing garbage Collector knows that object is no longer used and releases memory.

Best regards.

Hi Alexey

Yes, when a user refreshes their thumbnails, we iterate over the ArrayList storing the existing thumbnails and call Dispose() on each object contained therein. I’ve been using a .NET memory profiling application which tells me that the objects are “queued for finalization” which suggests that the finalizer task is blocking on some object somewhere else, with the result that the number of live Bitmap instances just keeps increasing and increasing with each refresh.

I’ve been reading up on the subject - it seems that the time the garbage collector chooses to release memory held by disposed objects is nondeterministic and thus cannot be relied upon to release memory in a timely fashion. So it’s quite a complex problem as you can see :slight_smile:

Eric

Hi Eric,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I suppose, you use code as provided here to generate thumbnails:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.document.rendertosize.html

Maybe you should save thumbnails to stream and use this stream instead of using Bitmap object. Please let me know if it is acceptable for you.

Best regards.