[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Re: FW: Bug#1812: KFM memory leak: updated patch for khtmlw.
From:       Waldo Bastian <bastian () suse ! de>
Date:       1999-08-31 14:57:21
[Download RAW message or body]

On Tue, 31 Aug 1999, Waldo Bastian wrote:
> > So the pCache->insert() call has to be replaced by pCache->replace().
> 
> Yes. It seems. 
> 
> That leaves the question why these images are cached in two seperate
> locations.
> 
> > Also I think it's a good programming practice to set the cache to autodelete.
> > One can argue if the cache clearing is really needed, but if we set the
> > threshold for clearing to a high enough number (higher than in the patch), it
> > won't hurt, if the cache doesn't fill up, and it helps in case it fills up. So
> > where's the problem?
> 
> I wouldn't change things like this 4 days before a release. I'll have a
> look at how this cache is used and if it indeed leaks as bad as the
> above would suggest. To be continued.

The use of this cache is strongly related to mimetypes. When browsing directories
a new entry is created for each new mimetype encountered. I noticed two types
of leaks: 

a) When two mimetypes use the same image, this image is added
twice to the pCache. This happens most often with images called "unknown.xpm".

b) When you call "rescan bindings" the mime types are flushed but the cached 
images aren't. 

The strange thing is that replacing this insert() call with replace() takes care of case 
a) but it doesn't seem to have an effect on b) at all.

I use the attached patch to test.

Cheers,
Waldo


["htmlobj.patch.diff" (text/x-c)]

Index: htmlobj.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtmlw/Attic/htmlobj.cpp,v
retrieving revision 1.69
diff -u -r1.69 htmlobj.cpp
--- htmlobj.cpp	1999/01/18 10:57:54	1.69
+++ htmlobj.cpp	1999/08/31 15:07:47
@@ -1282,7 +1282,13 @@
 	if( !pCache )
 		pCache = new QDict<HTMLCachedImage>( 503, true, false );
 
-	pCache->insert( _filename, new HTMLCachedImage( _filename ) );
+printf("cacheImage(%s)\n", _filename);
+if (pCache->find( _filename))
+	printf("FOUND!\n");
+	pCache->replace( _filename, new HTMLCachedImage( _filename ) );
+if (pCache->find( _filename))
+	printf("Item inserted succesfully!\n");
+printf("%d items in cache\n", pCache->count());
 }
 
 HTMLImage::HTMLImage( KHTMLWidget *widget, const char *_filename,


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic