Re: Linked List & Dynamic Memory Allocation
- From: one-trick-pony <worldofpain.aamir@xxxxxxxxx>
- Date: Mon, 27 Aug 2007 16:59:28 -0700
I know about that approach. In the book I have, the author is using
what you have described. I wanted to do something different-an attempt
at learning something. Best way is to actually practice it. I
understand what you meant by stack and heap. I just learned it in
different vocabulary. The books I have talked about "scope" which is
now I see linked with stack. For instance,
void dummy(int i)
{
i=4; //this i exists only in this routine
}
int main(void)
{
int i =0; <this i exists only here
dummy(i);
return 0;
}
I understand the scope rules in above example. I knew stack is
invovled when calling functions. Now I know that my array is on stack
but the last item which I added is on heap. Wonderful! Other than
that I already have example in the book that is doing this in C.
Last question is when malloc is used to allocate memory in a program
and a free function is not called, will OS do the "clean up" after
process is done executing and will it always lurk in the memory if OS
does not do clean up? It is a very simple program, I did forget to
include free call. Program seems to be running fine even with a
missing free call. Is memory in the back being filled and if I run
this program large number of times, it will end of exhausting system
resources? That is, its execution time is very tiny. User can quit
immediately or be there forever entering records. I guess if this
program runs long enough it will surely exhaust system memory. What
if it is executed then exited , then executed and then exited over and
over. Does it still have potential to bring system to its knees or
every time process ends, OS reclaims resources used by this process?
Thanks for help. I learned another way of thinking.
.
- Follow-Ups:
- Re: Linked List & Dynamic Memory Allocation
- From: Dan Bloomquist
- Re: Linked List & Dynamic Memory Allocation
- References:
- Linked List & Dynamic Memory Allocation
- From: one-trick-pony
- Re: Linked List & Dynamic Memory Allocation
- From: Jonathan Wood
- Re: Linked List & Dynamic Memory Allocation
- From: one-trick-pony
- Re: Linked List & Dynamic Memory Allocation
- From: Dan Bloomquist
- Re: Linked List & Dynamic Memory Allocation
- From: one-trick-pony
- Re: Linked List & Dynamic Memory Allocation
- From: Dan Bloomquist
- Re: Linked List & Dynamic Memory Allocation
- From: one-trick-pony
- Re: Linked List & Dynamic Memory Allocation
- From: Dan Bloomquist
- Linked List & Dynamic Memory Allocation
- Prev by Date: Re: OnInitDialog() in VS 2005
- Next by Date: Re: Is __int64 dead?
- Previous by thread: Re: Linked List & Dynamic Memory Allocation
- Next by thread: Re: Linked List & Dynamic Memory Allocation
- Index(es):
Relevant Pages
|
Loading