> > > You can test for memory leaks quite easily. Simply create a test (say, it > creates an instance of your class), and put it in a loop that executes, say, > 1000 times. Open up a memory viewer (for OSX it's just the Activity > Monitory) and load your page. Then reload it. You should see the memory > footprint reset on reload and return to were it was the first time you > loaded the page. If you see it step up and up each time you reload, you have > a leak. This is a little old, and I was running windows when I wrote it, but > it still mostly holds true: > > * *
As I’ve learned the hard way, accurately measuring memory usage is hard. --- Pavlov (Mozilla Engineer) The short summary is Windows Vista (Commit Size) and Linux (RSS) provide pretty accurate memory measurement numbers while Windows XP and MacOS X do not. On Mac, If you look at Activity Monitor it will look like we’re using more memory than we actually are. Mac OS X has a similar, but different, problem to Windows XP. After extensive testing and confirmation from Apple employees we realized that there was no way for an allocator to give unused pages of memory back while keeping the address range reserved.. (You can unmap them and remap them, but that causes some race conditions and isn’t as performant.) There are APIs that claim to do it (both madvise() and msync()) but they don’t actually do anything. It does appear that pages mapped in that haven’t been written to won’t be accounted for in memory stats, but you’ve written to them they’re going to show as taking up space until you unmap them. Since allocators will reuse space, you generally won’t have that many pages mapped in that haven’t been written to. Sorry but using Activity Monitor is flawed on so many levels. If you really need to nail down memory usage or suspect memory usage using some kind of profiler is essential. https://wiki.mozilla.org/Performance:Leak_Tools I know there are webkit specific resources as well, I'll try to dig them up. Drip seems to be a relatively easy to use and provides decent results for testing memory leaks within IE.