Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"01-14-09 - Allocator Alignment"

4 Comments -

1 – 4 of 4
Anonymous Anonymous said...

I guess you'd have to run simulations, but I would expect it to waste a lot of memory, yes. I'm not sure how it would shake out after a lot of freeing, but if you just sat there allocating 64K+1 byte over and over, you'd end up with 50% wastage.

Allocating to an alignment of the largest power of 2 that divides the requested size probably gets you what you want with less wastage. I didn't do that in our malloc because variable amounts of alignment would require extra overhead per malloc, which would suck at the low end.

January 15, 2009 at 4:05 PM

Blogger cbloom said...

BTW super-secret MS alignment disclosure :

http://msdn.microsoft.com/en-us/library/ycsb6wwf(vs.80).aspx

January 15, 2009 at 4:56 PM

Blogger cbloom said...

"Allocating to an alignment of the largest power of 2 that divides the requested size probably gets you what you want with less wastage"

Oh yeah, that's obviously better. Uh.. that's what I meant to say.

January 15, 2009 at 9:17 PM

Blogger Arseny Kapoulkine said...

16b malloc alignment is only for x64, if your application is 32 bit then it's 8b, so you have to override it to use i.e. SSE w/aligned loads.

As for alignment, it depends on the allocation needs of application - i.e. for allocating 4, 1024, 4, 1024, etc. bytes sequentially you'll get large overhead.

Why do you need it anyway? IMO explicit alignment is the only way to go for realistic usage. Perhaps along with larger default alignment (i.e. 16 instead of 8).

January 15, 2009 at 10:20 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.