art with code

2008-12-13

Filezoo day 33, part 1: memleak fixes


Had a few memleaks in the drawing loop. Pango.CairoHelper.CreateLayout leaks, especially when coupled with Pango.CairoHelper.ShowLayout. So now I'm using a lot of static variables in the text drawing path, which means that it's not thread-safe at all and I'm going to get bitten by it at some point. Creating gradients outside a using-block leaks as well. But now those are fixed and I can draw thousands of frames without the memory usage moving up from 40 megs.

I don't know if my thumbnail ImageSurfaces are space leaks. I do Destroy them. And yet I did dispose the Pango.Layouts as well. I couldn't push memory usage beyond 500 megs though, even with 4000+ thumbnails loaded (but eh, that's not a very rigorous test.) I think they do leak, since once I get mem use up to 300 megs with the thumbs, it's not coming back down.

The thumbnails in the image above take ridiculously long to load too. There are only 3300 drawn. Loading 3300 128x128 thumbnails should take... 0.75 ms per thumb, 2.5 seconds. Oh wait, those would be JPEG thumbnails. PNG thumbs, forever, yeah. I have just the thing for this thumbnail loading and drawing stuff though.

I also added some cache pruning. Now traversal cache is cleared when switching measurers. Which is a hack to enable manual pumping for correct information. And it shouldn't really be there in a perfect world.

In other news, now there's a bit dubious feature when drag-dropping text onto dirs and files. When you drop text onto a dir, it asks whether you want to create a new file. If you drop text on a file, you can either create a new file in the dir, replace the file contents with the text, or append the text to the file. Like mouse-driven xsel -o > file and xsel -o >> file.

Plan for the rest of the day:
  • Cut-Copy-Paste handling
  • Selecting files
  • Dragging files and selections

No comments:

Blog Archive