Questions tagged [heapalloc]

28 questions
11
votes
4 answers

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),…
Ondergetekende
  • 1,065
  • 9
  • 22
8
votes
2 answers

Is there a fundamental difference between malloc and HeapAlloc (aside from the portability)?

I'm having code that, for various reasons, I'm trying to port from the C runtime to one that uses the Windows Heap API. I've encountered a problem: If I redirect the malloc/calloc/realloc/free calls to HeapAlloc/HeapReAlloc/HeapFree (with…
user541686
  • 205,094
  • 128
  • 528
  • 886
8
votes
1 answer

(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…
Tony Stark
  • 24,588
  • 41
  • 96
  • 113
5
votes
2 answers

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; …
Anthony
  • 12,177
  • 9
  • 69
  • 105
3
votes
0 answers

malloc returns NULL and sets errno to ENOMEM, but there is plenty of heap space available?

I have a situation in which malloc() returns NULL and sets errno to ENOMEM. But the CRT heap (which is growable) has plenty of memory to work with. At the time of malloc, my process memory is about 900 MB. The host process is a Java executable…
Martin Frank
  • 199
  • 1
  • 13
3
votes
7 answers

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,…
Fábio
  • 3,291
  • 5
  • 36
  • 49
3
votes
2 answers

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 =…
Sorlaize
  • 33
  • 1
  • 3
2
votes
1 answer

Why system allocs more memory when using pointers Windows?

I use HeapAlloc to alloc a huge amount of memory, like 400 MB, but when i check the Memory Usage of my program it really uses like 1 GB. //configuraciones.h #define ANCHO_MUNDO 5000 #define ALTO_MUNDO 5000 //unidades.cpp unidad* unidades_memoria =…
felknight
  • 1,383
  • 1
  • 9
  • 25
1
vote
1 answer

Golang a huge difference in the number of pprof HeapAlloc and pprof heap inuse_space

I have a Golang program that just implements a simple business logic: establish a socket connection with the server-side program and maintain a business heartbeat. But when this connection does not transmit task data, the pprof report shows that…
Wang
  • 47
  • 3
1
vote
3 answers

HeapAlloc fails intermittently

We have a DLL (built using VC2005) that does some processing on behalf of the calling application. This processing requires quite a bit of memory. The DLL creates this memory via heapAlloc like so: //Allocate space myStruct* pStackSpace =…
Sam
  • 11
  • 1
  • 3
1
vote
2 answers

Calling malloc() from unmanaged DLL called within managed DLL generates access violation

I have a suite of tests written in C++/CLI that call into a native DLL in order to remotely test a Windows CE device. At two points during the test setup process, memory on the native heap is allocated--once for 512 bytes, the other for 572 bytes. …
1
vote
2 answers

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…
Benjamin
  • 10,085
  • 19
  • 80
  • 130
1
vote
1 answer

(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…
Tony Stark
  • 24,588
  • 41
  • 96
  • 113
1
vote
3 answers

(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…
Tony Stark
  • 24,588
  • 41
  • 96
  • 113
1
vote
1 answer

MASM dll memory allocation in multithreading application

I asked how to dynamically allocate memory in MASM here but I got 2 more questions. How can I allocate memory for bytes? .data tab DB ? result DB ? .code invoke GetProcessHeap ; error here mov tab, eax ; I cannot do this because of wrong…
Asker
  • 93
  • 7
1
2