heapalloc

Memory allocation on Windows C code

I'd like to know which method is recommended on Windows C programming: using malloc or the Win32 HeapAlloc (maybe VirtualAlloc?) function. I've read the MSDN Memory Management Functions article and the MSDN articles regarding malloc and HeapAlloc, but they do not say which one should be used and in what situations. ...

HeapAlloc returns 0xC0000017: Not Enough Quota

I'm allocating a small number of data types, total size 2mb. I only use one heap, and it runs fine until I get to a certain number of allocations, I'm pretty sure of this because I've commented one allocation for it to crash on the next. Quota = disk space? the documentation doesn't cover error codes for this specific function, I've pr...

What alignment does HeapAlloc use

I'm developing a general purpose library which uses Win32's HeapAlloc MSDN doesn't mention alignment guarantees for Win32's HeapAlloc, but I really need to know what alignment it uses, so I can avoid excessive padding. On my machine (vista, x86), all allocations are aligned at 8 bytes. Is this true for other platforms as well? ...

(C) Implementation tactics for heap allocators?

Where are some good resources for looking at the pros/cons of different ways of implementing heap allocators? Resources touching on efficiency (fragmentation, throughput, etc) are preferred. I am NOT looking for simple code repositories. edit: I'm not really interested in the philosophical grounding of this wiki. As such, I don't reall...

(C) how does a heap allocator handle a 4-byte block header, while only returning addresses that are multiples of 8?

It doesn't seem to make sense, unless we just ignore any potential excess space at the beginning of a segment, and then have the first allocated chunk be at the first multiple of 8 (with its corresponding first header being that address -4). This would leave however many bytes before that unused. Is that what's generally done? edit: tha...

(C) which heap policies are most often used?

I have heard that 'better-fit' is pretty commonly used, but I don't seem to read much about it online. What are the most commonly used / thought to be the most efficient policies used by heap allocators. (I admit my vocabulary may be flawed; when I say 'policy' i mean things such as 'best fit,' 'first fit,' 'next fit,' etc) Edit: I am ...

PIMPL and stack allocation

So I've been thinking about PIMPL and stack allocation. I've been writing a library and decided to use PIMPL to hide the private member of the class. That means I would have a class declared like this class Foo { private: class Handle; std::tr1::shared_ptr<Handle> handle; public: Foo(); }; It's pretty straight forward. But...

HEAP_NO_SERIALIZE flag.

When I called the HeapCreate function in the preceding code sample, I used the HEAP_NO_SERIALIZE flag because the remainder of the sample code is not multithread-safe. Jeffrey Richter wrote the sentence in his book(Windows via C/C++) But it's weird. If the codes are not multithread-safe he didn't have to use the flag. Is it a bug?...