Re: Linked List & Dynamic Memory Allocation



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.

.



Relevant Pages

  • Re: HPGCC how-to: Interacting with SysRPL
    ... it is recalling the entire C string to the stack and executing ... In order to keep your code in port memory and not use all that memory ...
    (comp.sys.hp48)
  • Re: If Macs have no spyware....
    ... >had made a complete code review of its operating system and removed all ... and writing new data into those memory locations would ... >but when the data exists on the stack, it can cause very large problems. ... >location that needs to be written in place of the correct execution ...
    (comp.sys.mac.advocacy)
  • Re: If Macs have no spyware....
    ... First you yammer about being a Mac advocate, then bad mouth me for dumping XP in favor of a Mac. ... Supposedly Microsoft had made a complete code review of its operating system and removed all the buffers which could overflow. ... the fundamental problem is that the basic architecture of Windows has two fatal flaws in its memory management and while these remain in the software the ad hoc patches will never be enough to make Windows a secure operating system. ... These problems are bad enough when dealing with data in the one routine but when the data exists on the stack, it can cause very large problems. ...
    (comp.sys.mac.advocacy)
  • Re: Maybe we should stop "Paging Beth Stone" already...
    ... I'll want to work on my OS while running my OS, so the assembler that it's written with has to run under it. ... You have to swap CR3 if you want seperate memory spaces. ... The alternate stacks aren't used by the processor unless the task calls a different protection level, so they're not part of the TSS swap. ... This lets any application use up to a gigabyte of stack before Linux is forced to tell it that it's gone too far. ...
    (alt.lang.asm)
  • Re: When is "volatile" used instead of "lock" ?
    ... to get the address of a stack variable to a background thread. ... I'm suggesting that the memory model ... lock pattern works without making the instance member volatile; ... fields shared amongst more than one thread despite following the locking ...
    (microsoft.public.dotnet.languages.csharp)

Loading