VB6 LoadPicture memory leak?
Posted on 2004-09-09
This is a tough one, but maybe someone out there knows the answer. Basically, I have a piece of code which reads in a multi-page TIFF file, then loops through each page, shrinking it and saving to a bitmap file, then loading that bitmap file back in via a call to LoadPicture and saving it to the IPictureDisp property of a thumbnail object I created. However, it seems that there's a memory leak associated with LoadPicture, because on anywhere between page 1000 and page 1400, I get an error #7, out of memory error, and it always occurs on the call to LoadPicture. My code calling LoadPicture is:
Set picTempPicture = LoadPicture()
Set picTempPicture = LoadPicture(strThumbnailBMP)
objThumb.ThumbnailImage = picTempPicture
I put in the call to LoadPicture() in the vain hopes that it would clear out the memory on each loop, but no such luck. I also split the assignment of objThumb.ThumbnailImage to LoadPicture into separate lines so as to verify that the out of memory error was occurring on LoadPicture and not on the assignment to objThumb.ThumbnailImage.
Does anyone have any knowledge of such a problem and how it can be fixed? I'm really stumped on this one, and searching on Google for LoadPicture and "out of memory" has come up dry. 500 points for this one...
William W. Lin