News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Strange Heap Behavior

Started by zooba, September 12, 2006, 01:51:44 PM

Previous topic - Next topic

zooba

Just noticed some strange memory behaviour in some code I've been playing with and was wondering if anyone could shed some light on what's going on.

Basically, I'm using HeapWalk to count the number of allocated bytes in the heap before and after doing a whole lot of stuff (sorry about lack of code, it's not in a suitable form for posting - might do it later).

When using the process heap, there are 8711 bytes allocated before and after running the code. When using a heap created with HeapCreate with initial size 1024, no maximum size and low-fragmentation heap enabled there are 31280 bytes allocated before and 75208 bytes allocated afterwards. Without the LFH enabled, there are 6144 bytes allocated before and after.

In all the documentation on the LFH I've read I've seen nothing about frees being delayed. Any ideas as to what is going on here?

Cheers,

Zooba :U

hutch--

It sounds like a variation of "deleyed write" and I have seen the effect with various types of memory allocations before. I am guessing what is happening is the final deallocation is dumped on a low priotity thread que and it can be a bit laggy because of it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zooba

Laggy by over 15 seconds (put a big Sleep in and tested again)...

Possibly the LFH allocates the buckets at the beginning and returns pointers to these when requested, so the allocations show up on a HeapWalk. There are probably more buckets allocated when the allocation sizes get bigger, hence an apparent memory leak which isn't there for other heaps.