Sponsored Content
Top Forums Programming Why memory allocated through malloc should be freed ? Post 302349200 by karthiktceit on Monday 31st of August 2009 09:53:22 AM
Old 08-31-2009
I understand that, But any part of the process's address space being leaked leads to a memory leak. But stack, data and text segments' memory is not at all leaked. Beacuse they are freed by the OS itself when a process terminates. But Heap alone needs to be freed explicitly. why is that so?
I use the "size"" command to find the size of each segment.

---------- Post updated at 07:23 PM ---------- Previous update was at 07:20 PM ----------

I understand your point matrix madhan. But can you expalin why the stack or data or text segment's memory is not leaked at all?
 

10 More Discussions You Might Find Interesting

1. Solaris

Memory allocated

Hi, How to find out what is the maximum memory allocated to TOMCAT server in SunOS 5.8? The Tomcat server crashes down during peak times.... Regards (1 Reply)
Discussion started by: baanprog
1 Replies

2. Programming

malloc gives the same memory to two different nodes. How to deal with it?

When allocating memory for two different nodes, the resulting memory are the same. Clearly, this will lead to a mistake. This happened in a function. And the process must be in a function. (gdb) p tree->list $43 = (node *) 0x8be4180 (gdb) p tree->list $44 = (node *) 0x8be4180 At the... (2 Replies)
Discussion started by: cdbug
2 Replies

3. Solaris

Memory usage in Solaris - memory not freed?

Hi, I'm running a multi-process software system on a Solaris 8 machine. When I monitor the memory usage, I see that the free memory is dropping rapidly, but I can't detect a process that uses this memory. I'm using "top" to get the free memory and the memory usage of processes. Thanks. (3 Replies)
Discussion started by: gewurtz
3 Replies

4. AIX

amount of memory allocated to large page

We just set up a system to use large pages. I want to know if there is a command to see how much of the memory is being used for large pages. For example if we have a system with 8GB of RAm assigned and it has been set to use 4GB for large pages is there a command to show that 4GB of the *GB is... (1 Reply)
Discussion started by: daveisme
1 Replies

5. HP-UX

how to find size of memory allocated to a pointer?

Hi, Am new to HP UX , is there a way to find out the size of memory allocated to a pointer on hp ux? For example we can use the _msize() on windows to find the size of memory allocated to a pointer . #include <stdio.h> #include <malloc.h> void main() { void *buffer; ... (0 Replies)
Discussion started by: Wkdunreal
0 Replies

6. Programming

Regarding the maximum memory allocated by malloc() function on HP-UX B11.11

In a 'C' program,when I am trying to allocate memory with the help of malloc () function, it is allocating the memory up to a certain limit for e.g. in my case, it is 670 MB (approx). malloc() returns NULL if I allocate more than this amount of memory.When I tried to allocate memory in chunks of... (1 Reply)
Discussion started by: vipinsachan
1 Replies

7. Programming

./match_pattern.out: malloc(): memory corruption: 0x0000000013a11600 ***

Hi All, I have a simple code which does some computation by matching string patterns. In brief: 1. The code reads .dat and .txt files. 2. .dat files are huge text files and .txt files contain some important words. 3. I am just doing strstr to find the patterns. 4. The function returns the... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

8. Programming

glib detected: malloc() memory curruption

I am using libxml2 library for XMl parsing and libxml++ is C++ wrapper over that. So I am using API of libxml++. I am creating my class and composing instance xmlpp::Node *pNode in that. my class also have funciton prepareXPathQuery() which creates query string and have other fucntion... (2 Replies)
Discussion started by: sharadwagh
2 Replies

9. Red Hat

KVM/Qemu allocated memory not showing in guest

So we have a RHEL 7.6 workstation with 128 gigs of ram. The OS sees all the ram and 80 cors (40 HT) We have 1 guest with 8 CPUs and 32gigs of ram running RHEL 7.6 workstation as well. We are trying to create another guest with 64 CPUs and 80 gigs of ram. We setup the system using... (0 Replies)
Discussion started by: joeg1484
0 Replies

10. UNIX for Beginners Questions & Answers

How to change allocated memory for a process?

Hello, I am running ubuntu 14.04 in a server with 32GB ram. Due to receiving "high load" errors during ssh connection, I took a look at what's happening from command line. I detected that 20GB of total memory was allocated to a program. Below you can see some initial part of installation... (4 Replies)
Discussion started by: baris35
4 Replies
maxdsiz(5)							File Formats Manual							maxdsiz(5)

NAME
maxdsiz, maxdsiz_64bit - maximum size (in bytes) of the data segment for any user process VALUES
Default Allowed values DESCRIPTION
User programs on HP-UX systems are composed of five discrete segments of virtual memory: text (or code), data, stack, shared, and I/O. Each segment occupies an architecturally defined range of the virtual address space that sets the upper limit to their size. However, text, data, and stack segments may have a smaller maximum enforced by the and tunables. This tunable defines the maximum size of the static data storage segment for 32-bit and 64-bit processes. The data storage segment con- tains fixed data storage such as globals, arrays, static variables, local variables in main(), strings, and space allocated using and Who is Expected to Change This Tunable? Anyone. Restrictions on Changing Changes to this tunable take effect only for processes started after the modification. In addition, a process which modifies its for the data segment propagates the modified limit to all child processes, thereby exempting them from any future modification of The value speci- fied is expected to be a multiple of the base page size. See the description of in getconf(1) for more details. If the value specified is not a multiple of the base page size, it will be rounded down to the nearest multiple of the base page size. When Should the Value of This Tunable Be Raised? This tunable should be raised if user processes are receiving the error message: or This may or may not cause a process failure depending on the program code. What Are the Side Effects of Raising the Value? Raising this tunable by definition allows larger data segments for every process. This means that and function as limitations on the amount of swap space that can be reserved or used by each process. Therefore, using more virtual address space does not translate directly into using more physical address space because virtual pages can be swapped out. If swap space on the machine is near capacity, raising this tunable increases the amount of reservable swap per process. This could exhaust the swap space on the system by allowing a process with a memory leak or a malicious program that uses huge amounts of memory to reserve too much swap space. When Should the Value of This Tunable Be Lowered? This tunable should be lowered if swap space is at a premium on the machine and programs that are using too much swap space are affecting the execution of other critical user processes. What Are the Side Effects of Lowering the Value? If swap space on the machine is near capacity, lowering this tunable will limit the amount of swap reserved for each process and will cause the processes that consume large amounts of swap space to receive the error. What Other Tunable Values Should Be Changed at the Same Time? The tunable should be considered because it also limits swap usage by process stack segment. WARNINGS
All HP-UX kernel tunable parameters are release specific. This parameter may be removed or have its meaning changed in future releases of HP-UX. Installation of optional kernel software, from HP or other vendors, may cause changes to tunable parameter values. After installation, some tunable parameters may no longer be at the default or recommended values. For information about the effects of installation on tun- able values, consult the documentation for the kernel software being installed. For information about optional kernel software that was factory installed on your system, see at AUTHOR
was developed by HP. SEE ALSO
getconf(1), getrlimit(2), setrlimit(2), maxtsiz(5), maxssiz(5). Tunable Kernel Parameters maxdsiz(5)
All times are GMT -4. The time now is 07:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy