- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Memory Handling is a problem with the compiler or ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-20-2002 08:12 AM
тАО03-20-2002 08:12 AM
Memory Handling is a problem with the compiler or OS ?
Pardon me if this question is a repetition.
When I use new/malloc in my code, memory gets allocated in the heap of the process. When I use free/delete it is released; but not back to the system. It retains the memory within the process so that it can make use of it in the next malloc/new call.
My doubt is, is this something to do with the compiler or OS ? There are system calls (mmap/munmap) that will explicitly release the memory back to the system from the process. Those calls are not being used/incorporated by the compiler, when it creates the binary. Am I right ? In that case, if I want to change the way in which delete/free behaves I need to change my compiler ... right ?
How expensive is to get memory from the system rather than from the process space ? Why does compilers do it this way ? How good will it be if I overload new/delete to behave in the other way ?
Please do reply
Thanks and Regards
Vishal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-20-2002 08:16 AM
тАО03-20-2002 08:16 AM
Re: Memory Handling is a problem with the compiler or OS ?
The answer is Neither.
http://docs.hp.com/cgi-bin/otsearch/getfile?id=/hpux/onlinedocs/os/11i/mem_mgt.html&searchterms=memory%20management&queryid=20020320-082233
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-20-2002 08:20 AM
тАО03-20-2002 08:20 AM
Re: Memory Handling is a problem with the compiler or OS ?
This is normal behavior. When you use malloc(), calloc(), or realloc() to allocate memory and then use free() to release the memory, it is not returned to the OS. It is returned to the process's heap for further use by more malloc()'s. You can use the sbrk() system call with a negative value to return memory to the OS but this is not for the faint of heart. If you choose to use sbrk() you MUST NOT USE the higher-level malloc() related functions or absolute chaos will result. If you you sbrk(), you assume full responsibility for process memory management.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-20-2002 09:31 AM
тАО03-20-2002 09:31 AM
Re: Memory Handling is a problem with the compiler or OS ?
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-20-2002 11:09 AM
тАО03-20-2002 11:09 AM
Re: Memory Handling is a problem with the compiler or OS ?
Something else you may want to investigate is a garbage collector such as that available from HP labs:
http://www.hpl.hp.com/personal/Hans_Boehm/gc/
I'm not sure this will do exactly what you want (ie release memory back to the OS through calls to sbrk with negative arguments) because I haven't had a chance to try it out myself, but it does contain replacements for the malloc/free routines and the source code is all there. It also works with C++'s new and delete operators.
Regards,
Steve