>How to check memory usage by a program by writeing a C program.
A profiler is used for such purposes.
>When the program terminates and we didnot free it what happens exactly?
Most OSes (this means: not all!) clean up all the memory assigned to a program when the program shuts down, but it's dangerous to rely upon this when writing software.
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Sorry I misunderstood you.
>can we do it using C?
Using standard C: no.
Using the OS's API: yes.
>i mean to say a function which i can call in between inside a program to check memory usage.
What exactly must this function check then?
Only memory occupied within the program, or also memory occupied by other programs running?
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
http://c-faq.com/malloc/index.html
* Memory leak
Calling malloc() without calling free().
* Buffer OverFlow
Accesses outside the bounds of your memory. Can equally apply to arrays as well as allocated memory.
A typical example is a for loop which runs to <=N rather than
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Dream2Code,
Sure you didn't mean:
a=strst<strong>r</strong>(b,"name");
instead of: a=strste(b,"name");
?
I assume this was a typo because probably ther-key comes just after the e-key on your keyboard.
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243