How OS tackles mem. freed by free method

A

apoorv

Hi Guys,
My doubt is like I am having a program that creates a linked stack.On
poping I am freeing memory.But I read some where though we free it but It
cant be used by us immediately here comes some role of OS.How OS does this
because we have sever programs that run for days together??????
 
M

Mark McIntyre

Hi Guys,
My doubt

you mean your question? Or your problem?
is like I am having a program that creates a linked stack.On
poping I am freeing memory.But I read some where though we free it but It
cant be used by us immediately here comes some role of OS.How OS does this
because we have sever programs that run for days together??????

The anser to this depends on the OS. You ought to ask again in the group
specialising in the OS you're interested in, because the answer is not C
related.
 
S

SM Ryan

# Hi Guys,
# My doubt is like I am having a program that creates a linked stack.On
# poping I am freeing memory.But I read some where though we free it but It
# cant be used by us immediately here comes some role of OS.How OS does this
# because we have sever programs that run for days together??????

In any malloc library you're likely to use, freed memory becomes available for
subsequent mallocs. Whether the freed memory is counted as part of the process
or no, it will be recycled on any system you're likely to use.
 
R

Richard Bos

SM Ryan said:
# My doubt is like I am having a program that creates a linked stack.On
# poping I am freeing memory.But I read some where though we free it but It
# cant be used by us immediately here comes some role of OS.How OS does this
# because we have sever programs that run for days together??????

In any malloc library you're likely to use, freed memory becomes available for
subsequent mallocs. Whether the freed memory is counted as part of the process
or no, it will be recycled on any system you're likely to use.

To the same program, yes. Not necessarily to other programs; and you may
not see the program's memory use go down in any OS tools. This might be
what's confusing the OP.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top