(part 39) Han from China answers your C questions



Size of a process

mysorepushpa@xxxxxxxxx said:
Suppose I have a C program in which I would have done a couple of
mallocs which amounts upto 1MB. Assuming the size of the program is
around 100KB for other things like code, data and other stuff. Will
this malloc size be counted in the size of the program when the exe is
created for the program.

I would say no, since malloc() belongs to the DYNAMIC memory allocation
family, and memory allocated by malloc() doesn't usually account for
space in the binary file (nor does automatic storage for local variables
and such). On systems with the typical heap and stack mechanisms, space
is allocated and deallocated at run-time. However, the computing world
teaches us not to trust absolutes, so there may be some compiler or whatever
out there that preallocates a certain amount of space for dynamic allocation
requests.

Yours,
Han from China

All my posts will have subjects containing the words "Han from
China" or "Han from China's". This is so people can killfile me
easily if they wish. There are 3 posting IDs that my gateways
randomly assign me: George Orwell, Nomen Nescio, and Borked
Pseudo Mailed. You can killfile those too if you wish. Other
than that, my posts have a highly consistent format as well.
Thank you and good luck with your C programming.

.



Relevant Pages

  • Re: dynamically allocated memory
    ... memory allocation function fails, they take memory from the emergency pool. ... they replenish the emergency pool. ... all the mission-critical applications I have managed that started on straight 'malloc' eventually migrated to their own memory allocators. ... have been reasons for malloc replacement in systems I've been involved with. ...
    (comp.unix.programmer)
  • Re: Malloc Query
    ... amount of overhead in terms of calling the same. ... significant advantage in providing user defined malloc() and free. ... memory allocation and de-allocation in a much better way than what OS ... They go on to call an OS space allocator ...
    (comp.lang.c)
  • Re: dynamically allocated memory
    ... > memory allocation function fails, they take memory from the emergency ... they replenish the emergency pool. ... I'm aware that really mission critical apps rarely use malloc ...
    (comp.unix.programmer)
  • Re: Memory allocation problem
    ... Linux follows an optimistic memory allocation strategy. ... This means that when malloc() returns non-NULL there is no guarantee ... But the mallocbug is still there. ...
    (alt.os.linux)
  • Re: Locking, locking...
    ... > As we all knew size of list could be changed when we were in malloc(). ... Recall memory allocation? ... increase and decrease it repeatedle. ... then there is a DoS in terms of memory allocation anyway. ...
    (freebsd-hackers)