each program has its own address space in memory. therefore, if eachQuote:>If I have five identical programs running on 5 ttys, does each program have a
>copy of its code in memory, or do they share the same code?
program required, say, 1M of memory for execution, then the five programs
would require 5M of memory.
you are correct in assuming that the entire memory of the program would beQuote:>Also, does exit() automatically release memory allocated by malloc(), or does
>free() have to be called explicitely? I would assume the entire program's heap
>would be released on exit(), but I am not sure. I am trying to figure out why
>sar only reports ~1 Meg of freemem on a 16 Meg i486 system (Microport SVr4
deallocated on exit(). however, if you wish to use some memory previously
allocated by malloc() within the same program itself, then you need
to explicitly free it using free() or realloc(). also, it might be a good
idea to set the variable that was pointing to memory before free()
was called on it to NULL immediately after freeing it.
hope this helps...
218 N Hyland Avenue #302 237 Wilhelm
Ames, IA 50014 Scalable Computing Laboratory