Alexander R. Pruss:

> I am concerned a little about memory usage and caching. ...

> [ Memory only freed when the document is released;
>  other functions may start to fail for low memory.]

cache.c/AddToCache does the right thing, and removes
the oldest entry if there isn't enough space. 

cache.c/AddPtrToCache doesn't bother to check because
*it* is only adding a few bytes; the data is already out there.
Unfortunately, the image.c caller assumes (quite reasonably) 
that the cache will manage all the memory.  

Before adding the node, it should probably do the same 
checking that AddToCache does, in case memory has 
become scarce outside the cache.  (Code below as example, 
not tested.)

        /*
        Check if we need to shrink the cache. 
        If 0 bytes is too much to ask for, then 
        we need to free some cache.
        */
        while (FreeSpaceAvailable(0) && 
                ListSize(cache))
        {
                RemoveFromCache( ListFirst( cache ) );
        }

        /*
        Now add the new node, which we know we don't want 
        to free yet.
        */
  
Note that FreeSpaceAvailable() automatically adds the minimum
it wants to leave for other processes - currently 1024768, which
is probably enough.

-jJ
_______________________________________________
plucker-dev mailing list
[EMAIL PROTECTED]
http://lists.rubberchicken.org/mailman/listinfo/plucker-dev

Reply via email to