Heap in Linux

Hi yours,

I am doing a simulation for studying purposes,
and need to know how Heaps are implemented in linux.
With a Heap I mean the memory managing thing, the thing you get by GetProcessHeap()
and not the mathematical datastructure of the same name.
I would like to hear some detailled explaination of the basic algorithms running
and the Heaps features.
Thanks in advance, drnick.

p.s. i'm asking this for windows in another thread too
LVL 5
drnickAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

drnickAuthor Commented:
sorry, copy-paste-error: GetProcessHeap is windows, okok
majorwooCommented:
drnick,

Seems alot like homework (which we are not allowed to do as you know) -- maybe start us off with what you know, and ask some more specific questions?

majorwoo
drnickAuthor Commented:
hi majorwoo,

I understand you concers well.
maybe i gotta specify a little more what i mean.
my question targets into that direction:
i am interested in how they work internally, what data structures and algorithms they use.
if i do HeapAlloc (in windows), for sure it will allocate memory for me,
but how does it this?
does it use kinda best-fit on a sequential set of memory pages, or returns it the first fitting free block?
is free memory handled by a free-space-list or do they come with buddy-processing?
I need to know this, because i am writing a simulation for heaps in general.
therefore, i asked this question on different os'es,
to let the use have a drop down list where she/he can decide, what os to simulate.
for academic purposes, you know.
so, this question is also not a homework, if any doubt occures, the programming will of course be done by myself, i just need some hints to make the simulations as precise as possible.
also, as you can see under my profile, i am a guy who has already answered some questions here, in different areas (and an average-a-student, who really would never ever ask someone to do his homework, to set record straight).
the thing is this: i am doing this for an international project for teaching of computer studies, the simulation'll be for other students and i'm doing this for zero money.
i have to do other stuff as well, and the only time, i can do some work on this, is sunday and tuesday afternoon, so i just want to enhance my perfomance with this question.
if experts maybe can describe in a short, understandable way, how the heap in their os works, and what it's main parameters are, i can process a lot faster.
If you're still questioning my integrity, than it is ok if you don't answer.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

drnickAuthor Commented:
however, i elaborated on my question in the mac-os section a little more, so maybe that'll help anyone who wanna help me. thanks
sunnycoderCommented:
drnick,

Is it that you are looking at heap organization for the entire system or what is the algorithm used for memory allocation on the heap?

If former, then I think source at dmalloc.com might be helpful in deciphering the required information ...sorry I am not familiar with the organization of overall heap or for that matter who creates/maintains it

However, if you are looking at algorithm used for memory allocation on the heap, then it depends entirely on the implementation of the malloc function in your library .. system/compiler has nothing to do with it ...

generally,

a list of free memory blocks of different sizes is maintained ... this size is generally (mostly) power of 2 ... the minimum size maintained is the minimum amount of memory that can be allocated ... even if you request lesser memory, a whole block will be allocated.

When an allocation request is made, the smallest available block that will satisfy the request is returned ... If request cannot be satisfied, NULL is returned

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Karl Heinz KremerCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by sunnycoder
Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

khkremer
EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.