heap space vs. paging space (what does free() do?)

heap space vs. paging space (what does free() do?)

Post by Rob Yampolsk » Sat, 02 Dec 2000 04:00:00



On my AIX3.2.5 system (haven't checked on AIX 4 yet), I have a program
that malloc's a very large buffer.

When I free the buffer, the paging space associated with it does not
seem to go away.  In other words, lsps -a reports the same percentage of
paging space in use after the buffer is free'd as before.

Is this really the way it works?  The heap for your application remains
allocated up to the 'high-water mark' of the most memory you allocate at
any given time?

If so, is there some library function you can call to explicitly shrink
the heap back?

Could it be possible that the system would reallocate paging space
dedicated to 'unallocated heap space' if another app came along and
needed it?

Thanks,
Rob Yampolsky

 
 
 

heap space vs. paging space (what does free() do?)

Post by Kevin Bran » Sat, 02 Dec 2000 04:00:00


You are correct.

Use disclaim() function to really free your memory back to the OS ( and
other applications/users )...

-Kevin


> On my AIX3.2.5 system (haven't checked on AIX 4 yet), I have a program
> that malloc's a very large buffer.

> When I free the buffer, the paging space associated with it does not
> seem to go away.  In other words, lsps -a reports the same percentage of
> paging space in use after the buffer is free'd as before.

> Is this really the way it works?  The heap for your application remains
> allocated up to the 'high-water mark' of the most memory you allocate at
> any given time?

> If so, is there some library function you can call to explicitly shrink
> the heap back?

> Could it be possible that the system would reallocate paging space
> dedicated to 'unallocated heap space' if another app came along and
> needed it?

> Thanks,
> Rob Yampolsky



 
 
 

heap space vs. paging space (what does free() do?)

Post by Rob Yampolsk » Sat, 02 Dec 2000 04:00:00


Thanks for the quick reply.

Rob


> You are correct.

> Use disclaim() function to really free your memory back to the OS ( and
> other applications/users )...

 
 
 

heap space vs. paging space (what does free() do?)

Post by Rob Yampolsk » Sat, 02 Dec 2000 04:00:00


I took a look at the man page, and
1. Found disclaim on AIX, but not Linux.
2. Found another function,  munmap(), that looks similar and is present
on both systems.
3. Man pages talk about shared memory, and reference the shmat function
in their 'see also' sections.

So, is it okay to use munmap() and is it okay to use either of these
functions for plain malloc'd memory?
If so, do you call munmap() instead of free() or after calling free()?

Thanks,
Rob Yampolsky


> You are correct.

> Use disclaim() function to really free your memory back to the OS ( and
> other applications/users )...

 
 
 

heap space vs. paging space (what does free() do?)

Post by Rob Yampolsk » Sat, 02 Dec 2000 04:00:00


I took a look at the man page, and
1. Found disclaim on AIX, but not Linux.
2. Found another function,  munmap(), that looks similar and is present
on both systems.
3. Man pages talk about shared memory, and reference the shmat function
in their 'see also' sections.

So, is it okay to use munmap() and is it okay to use either of these
functions for plain malloc'd memory?
If so, do you call munmap() instead of free() or after calling free()?

Thanks,
Rob Yampolsky


> You are correct.

> Use disclaim() function to really free your memory back to the OS ( and
> other applications/users )...

 
 
 

heap space vs. paging space (what does free() do?)

Post by Rob Yampolsk » Sat, 02 Dec 2000 04:00:00


(sorry if this is a duplicate - weird error message from Mozilla last
time, when I tried 'Reply All')

I took a look at the man page, and
1. Found disclaim on AIX, but not Linux.
2. Found another function,  munmap(), that looks similar and is present
on both systems.
3. Man pages talk about shared memory, and reference the shmat function
in their 'see also' sections.

So, is it okay to use munmap() and is it okay to use either of these
functions for plain malloc'd memory?
If so, do you call munmap() instead of free() or after calling free()?

Thanks,
Rob Yampolsky


> You are correct.

> Use disclaim() function to really free your memory back to the OS ( and
> other applications/users )...

> -Kevin

 
 
 

heap space vs. paging space (what does free() do?)

Post by Greg Wimpe » Sat, 02 Dec 2000 04:00:00



> (sorry if this is a duplicate - weird error message from Mozilla last
> time, when I tried 'Reply All')

> I took a look at the man page, and
> 1. Found disclaim on AIX, but not Linux.
> 2. Found another function,  munmap(), that looks similar and is present
> on both systems.
> 3. Man pages talk about shared memory, and reference the shmat function
> in their 'see also' sections.

> So, is it okay to use munmap() and is it okay to use either of these
> functions for plain malloc'd memory?
> If so, do you call munmap() instead of free() or after calling free()?

No, munmap() won't do what you want.  Quoting from the AIX 4.3 man page:

"The munmap subroutine unmaps regions created from calls to the mmap
subroutine only."

What you want to do involves the computer science problem known as
garbage collection.  I'm sure there are many computer science texts
that will outline possible solutions to this problem. The problem arises
because, as you malloc() and free() memory, the heap becomes fragmented.
The O/S has no clue as to how much of the heap is actually in use,
so there is no way for the system to automatically shrink the heap.

The brk()/sbrk() library functions might do what you want.  They
change the size of the process data segment.  In fact, I believe that
malloc() calls brk() to extend the data segment as necessary.

However, if you are going to do garbage collection, do it carefully,
or you might end up releasing memory that's in use back to the system.
The next time your program attempts to use that released memory,
you'll get a segmentation violation.

--

 
 
 

1. memory space vs page space

I currently have 1.5g ram and 1g page space (being 50-60% used) on 7026-H70,
4.3.2, HACMP, SSA raid5 array, running Oracle.  The internal rootvg drives are
4.5g and have about 700m available which limits my space to increase the paging
space.  I understand IBM recommends keeping ram and paging somewhat equal in
size but that is not an immediate option in this case.  What problems should I
look for if I increase the memory to 3g but do not increase the page space?  Is
there a realworld rule of thumb for the allocation of memory vs paging space?  

2. samba

3. Solaris 2.6, "minfree", 10% free space, tunefs and time vs space

4. Some Simple Good News

5. Wipe out DOS partition and add the free space to Linux

6. Slakware 3.0 Man Pages

7. df with UMSDOS/dir with dos disagree on free space

8. LinuxPPC2000 HELP ME!

9. device out of space-can't free up space

10. 30 GB free space and still "no enought space"

11. Paging space size (NOT swap space size)

12. VMWare = Swap space on Host Linux and paging space for Guest OS

13. Paging space & File System space