[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Ridiculous memory usage!



On Mon, 2 Jun 2003, Jarek Zgoda wrote:

>Dnia Mon, Jun 02, 2003 at 12:54:01PM +0000, Curtiss Howard pisze:
>
>>I've written a program which is a "front-end" (menu system) for various
>>emulators.  Whenever a game is highlighted on the menu a screenshot of
>>the game is displaed "in the background" (that is, stretched to fill
>>the screen and blitted before any foreground stuff).  The images are
>>all PNG files with resolution approximately 320x240 or so (some
>>slightly bigger, most are smaller) and they are being stretched to
>>800x600 at run time.  The problem?  Insane memory consumption!  There
>>are about 50 images total that are loaded all at once and Python is
>>using up somewhere in the neighborhood of 130MB!  I've checked and
>>images are loaded once and only once.  The only explanation for this
>>behavior that I can think of is that Pygame is keeping an 800x600x32
>>"raw copy" of every image in memory.  Is there no better way than that?
>
>The images are converted to screen format (size and color depth), so it
>seems possible.

Yeah, a raw format is most efficient (fastest) to blit with no extra
processing, so that is what you'll get. 

Have you tried loading the images on demand only and stretching them on
the fly? Is it ioo slow?

-- 
        Five exclamation marks, the sure sign of an insane mind.
                                              -- Terry Pratchett, Reaper Man