flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
vivik
Anybody have a code for 16-byte (or even better if I can pass required alignment as one of parameters) allocator? Preferrably in pure winapi.
|
|||
![]() |
|
Furs
VirtualAlloc allocates in chunks of 4k bytes (pages), it may be overkill or not, up to your use case. (alignment is guaranteed to be 4096 bytes obviously)
|
|||
![]() |
|
revolution
VirtualAlloc is a little it more complicated than a simple 4kB alignment though.
The page size is not actually guaranteed to be 4kB. While is it probably true that every existing and previous x86/x64 Windows version does use 4kB, it is still prudent to check the actual page size in use by calling GetSystemInfo. Future proofing and all that. |
|||
![]() |
|
Furs
But I doubt they'd use smaller pages which aren't even supported by the CPU (likely they'd be larger), which still means 4096 alignment is guaranteed, just not more. Anyway, depending on his use case, it's just an alternative. If he does a lot of allocations then it's overkill and will be inefficient. Still something to keep in mind.
|
|||
![]() |
|
revolution
When you mention "doubt" then you should already start to take measures to fix that - Call GetSystemInfo. Then no more doubt needed. It is easy to do. Why assume when you can know?
|
|||
![]() |
|
vivik
Hoped for an allocator that works on top of VirtualAlloc, maybe somebody made something like that already.
About future proofing, I'll probably just release source code. |
|||
![]() |
|
alexfru
Look up HeapAlloc(). It isn't as wasteful as VirtualAlloc(). AFAIK, it returns 8-byte aligned addresses.
|
|||
![]() |
|
vivik
SSE requires 16-byte alignment though.
I heard it's actually 16-byte aligned on 64-bit windows, but I'm targeting 32-bit windows for now. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.