Re: Slow down - memory resource increase

Bob Friesenhahn <[email protected]> Fri, 8 Apr 2005 09:22:42 -0500 (CDT)
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
On Fri, 8 Apr 2005, Stefan v. Wachter wrote:

> Again I want to point out that there is sometimes a difference between the 
> resource memory amount managed by resource.c and the actually used heap 
> memory of the GraphicsMagick process. In my case the resource memory 
> constantly grew until it reached the memory limit. Then it switched to disk 
> cache causing the slow down. Meanwhile the heap memory was almost constant! 
> (I fixed the memory leak and the [MVG] issue.)
>
> Finally I found two sources of my problems with the increasing resource 
> memory:
>
> First - in cache.c OpenCache the size for the pixel buffer (the offset var) 
> is computed twice in different ways. In the case of a DirectClass image the 
> results differ and generate a difference between the resource management and 
> the actually occypied heap memory.

I assume that the problem you found is here:

   cache_info->length=offset;
   /*
     Assure that there is sufficient address space available to contain
     the PseudoClass representation (PixelPacket array + colormap
     indexes array), and assure that there are sufficient memory
     resources remaining. Pre-allocate sufficient memory to store the
     PseudoClass representation in order to reduce the chance of
     running out of virtual memory while processing the image. If the
     operating system does not reserve heap allocations then it is
     still possible to run out of virtual memory (the process will be
     killed) even after the memory has been allocated.
   */
   offset=number_pixels*(sizeof(PixelPacket)+sizeof(IndexPacket));
   if ((offset == (magick_off_t) ((size_t) offset)) &&
       (AcquireMagickResource(MemoryResource,offset)) &&
       ((cache_info->type == UndefinedCache) ||
        (cache_info->type == MemoryCache)))
     {

If so, then that means I added this bug. :-(

In this case, the value cached in cache_info->length does not match 
the memory actually requested so the amount released is less than was 
requested.  Oops!

Bob
======================================
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click