Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Programming Threads > sup****ting hea...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 28 Topic 4066 of 4146
Post > Topic >>

sup****ting header-less blocks in memory allocators...

by "Chris M. Thomasson" <no@[EMAIL PROTECTED] > Oct 2, 2008 at 07:28 AM

I was thinking of an idea of expanding a current limitation in some of my 
allocators which sup****t the use of header-less blocks. The way I
currently 
do it is to simply align chunks on a fairly large boundary, say 16 pages. 
These chunks contain a header at the head. Layout is simple:

[H][CHUNK]

A 16-page chunk would be aligned on a 16-page chunk boundary. If a 
header-less block needs to access its header, it simple rounds its address

up to a chunk boundary, and subtracts the size of the chunk plus the size
of 
the header. This has a limitation that the largest memory allocation can't

be larger than the size of a chunk. To overcome this, I was thinking about

generating a unique GUID per-computer, and using that as a header 
identifier. The header would store the GUID right after it. So, the layout

for a multi-chunk allocation would look like:


[H][GUID][CHUNK1][CHUNK2]


Now, when a header-less block needs to find its chunk header it simply, 
rounds its address up to a chunk boundary; subtracts the size of the chunk

plus the size of the GUID; compares the existing memory contents with the 
GUID; if it does not find a match, it subtracts the size of the a chunk 
minus the size of the GUID and repeats the comparison. This process is 
repeated until a match is hit. After that, it subtracts the size of the 
header, and bingo, it has a pointer to its chunk header.

The process is simple but is has a caveat! If for some reason, the memory 
contents of a chunk that is not the true header just happens to contain
data 
which matches the GUID, well, BOOOOOM!!!!!!! Oh ****%!!! The program will
be 
royally screwed... OUCH!


First of all, what do you think of the scheme?


Also, are there better ways to sup****t 100% header-less blocks in a memory

allocator? IMVHO, header-less blocks are a MAJOR plus when designing
highly 
efficient memory allocation implementations. Think about it... A 4-byte 
allocation actually means 4-bytes are allocated internally. No 4-bytes
plus 
internal block header information! That's crap and totally wastes memory
on 
a per-allocation basis; which can quickly add up indeed.


There is a way to minimize the GUID scheme, but it requires two sections
of 
virtual memory which can be wasteful. It involves block sizes <= chunk
size 
to be allocated from a separate memory pool than block sizes that are > 
chunk size. The former can use the normal scheme of simple rounding up and

subtracting to get chunk header... However, the latter would need to use
the 
GUID search algorithm.




any thoughts?


BTW, does any of you know off-hand if Hoard uses header-less blocks?




Thanks for your time!
 




 28 Posts in Topic:
supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 07:28:39 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 07:30:14 
Re: supporting header-less blocks in memory allocators...
Eric Sosman <Eric.Sosm  2008-10-02 10:55:36 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 10:17:04 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 14:47:48 
Re: supporting header-less blocks in memory allocators...
"Dmitriy V'jukov&quo  2008-10-02 08:41:31 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 09:29:16 
Re: supporting header-less blocks in memory allocators...
"Dmitriy V'jukov&quo  2008-10-02 11:00:02 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 11:50:57 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 11:55:02 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 12:20:25 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 12:30:51 
Re: supporting header-less blocks in memory allocators...
"Dmitriy V'jukov&quo  2008-10-02 12:00:46 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 12:30:09 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 12:38:26 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 12:48:45 
Re: supporting header-less blocks in memory allocators...
Michel Decima <michel.  2008-10-03 13:56:34 
Re: supporting header-less blocks in memory allocators...
"Dmitriy V'jukov&quo  2008-10-02 12:07:41 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-03 22:41:41 
Re: supporting header-less blocks in memory allocators...
"Dmitriy V'jukov&quo  2008-10-02 12:24:01 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 12:32:18 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-02 12:35:16 
Re: supporting header-less blocks in memory allocators...
"Dmitriy V'jukov&quo  2008-10-03 03:40:04 
Re: supporting header-less blocks in memory allocators...
"Dmitriy V'jukov&quo  2008-10-03 03:42:50 
Re: supporting header-less blocks in memory allocators...
"Dmitriy V'jukov&quo  2008-10-03 05:52:20 
Re: supporting header-less blocks in memory allocators...
Michel Decima <michel.  2008-10-03 15:28:13 
Re: supporting header-less blocks in memory allocators...
"Chris M. Thomasson&  2008-10-03 22:19:59 
Re: supporting header-less blocks in memory allocators...
"Dmitriy V'jukov&quo  2008-10-06 00:02:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 9:38:01 CST 2008.