3

Is there some way to align HeapAlloc?

There is _aligned_malloc, but I'd like to use HeapAlloc since I frequently allocate memory on a private heap.

4
  • 2
    For C, see How to allocate aligned memory only using the standard library?. You'd use the result from HeapAlloc() in place of malloc(), presumably. I don't think there's a simple alternative for C++ — the languages C and C++ are different, and never more so than in the area of memory management. Commented Jul 13, 2020 at 21:31
  • Like I said, man, there's also the _aligned_malloc function I know of, but these functions allocate memory on the process' default heap, while I wish to allocate memory on a private heap since whenever I allocate large amounts of data on the process heap then free it, it does not get released back to the OS the majority of the time, while if I destroy my private heap it is. Commented Jul 13, 2020 at 21:33
  • Read the answer — it covers how to deal with allocations as if from HeapAlloc(). It only got edited to mention aligned_alloc(), which is the C11 standard function for aligned allocation, a number of years after it was first written. Commented Jul 13, 2020 at 21:34
  • My bad, I just skimmed over it quickly. Commented Jul 13, 2020 at 21:35

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.