* Memory Management
@ 2000-11-14 5:00 root
2000-11-16 4:25 ` Park, Byoung-Kyu
2000-11-17 5:00 ` Nikola Milutinovic
0 siblings, 2 replies; 9+ messages in thread
From: root @ 2000-11-14 5:00 UTC (permalink / raw)
This is a historic question.
We upgraded from Tru64 3.2G to Tru64 4.0F some time ago. When we ran
our application on 4.0F we started getting "Low swap space" warnings
that we did not get under 3.2G.
Looking at the VSIZE column of the 'ps' output I noticed that under 4.0F
memory allocated to a process is not released back to the operating
system - i.e. VSIZE only ever increases. Under 3.2G the
VSIZE fluctuates up and down.
I wrote the following simple test C program:
#include <stdio.h>
#include <stdlib.h>
#define MB (1024*1024)
void main(void)
{
char *mem_block1;
char *mem_block2;
mem_block1 = (char *)malloc(50*MB);
mem_block2 = (char *)malloc(50*MB);
getchar(); /* give chance to run ps */
free(mem_block2);
get_char(); /* give chance to run ps */
}
Under 4.0F the VSIZE is approx 100Mb + some process overhead
Under 3.2G the VSIZE is approx 50MB + some process overhead.
Unfortunately I no longer have access to the 3.2G box.
Does anyone know for certain if the memory management was changed from
3.2, in which malloc()/free() off-loaded all memory management to the
kernel, and 4.0F which appears to expect the user processes to manage
free space with malloc()/free()? I'm guessing this change (if I'm
right) was made for kernel efficiency - for example, less scanning of
free lists, less swap allocation/deallocation activity, etc.
Regards,
Hugh Patrick
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Memory Management
2000-11-14 5:00 Memory Management root
@ 2000-11-16 4:25 ` Park, Byoung-Kyu
2000-11-17 2:07 ` Hugh Patrick
2000-11-17 5:00 ` Nikola Milutinovic
1 sibling, 1 reply; 9+ messages in thread
From: Park, Byoung-Kyu @ 2000-11-16 4:25 UTC (permalink / raw)
Checking the swap area.
=> #swapon -s
Program executing is memory load and allocation swap space.
so, messages display that low swap space
ex> recommand swap space = Physical memory * 2.5 or 3.0
"root" <hugh.patrick@virgin.net> wrote in message
news:3A11AFE6.194B9261@virgin.net...
> This is a historic question.
>
> We upgraded from Tru64 3.2G to Tru64 4.0F some time ago. When we ran
> our application on 4.0F we started getting "Low swap space" warnings
> that we did not get under 3.2G.
>
> Looking at the VSIZE column of the 'ps' output I noticed that under 4.0F
> memory allocated to a process is not released back to the operating
> system - i.e. VSIZE only ever increases. Under 3.2G the
> VSIZE fluctuates up and down.
>
> I wrote the following simple test C program:
>
> #include <stdio.h>
> #include <stdlib.h>
> #define MB (1024*1024)
> void main(void)
> {
> char *mem_block1;
> char *mem_block2;
>
> mem_block1 = (char *)malloc(50*MB);
> mem_block2 = (char *)malloc(50*MB);
> getchar(); /* give chance to run ps */
> free(mem_block2);
> get_char(); /* give chance to run ps */
> }
>
> Under 4.0F the VSIZE is approx 100Mb + some process overhead
> Under 3.2G the VSIZE is approx 50MB + some process overhead.
>
> Unfortunately I no longer have access to the 3.2G box.
>
> Does anyone know for certain if the memory management was changed from
> 3.2, in which malloc()/free() off-loaded all memory management to the
> kernel, and 4.0F which appears to expect the user processes to manage
> free space with malloc()/free()? I'm guessing this change (if I'm
> right) was made for kernel efficiency - for example, less scanning of
> free lists, less swap allocation/deallocation activity, etc.
>
> Regards,
> Hugh Patrick
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Memory Management
2000-11-16 4:25 ` Park, Byoung-Kyu
@ 2000-11-17 2:07 ` Hugh Patrick
2000-11-17 5:00 ` Robert Mulley
0 siblings, 1 reply; 9+ messages in thread
From: Hugh Patrick @ 2000-11-17 2:07 UTC (permalink / raw)
Does this assume that the system was configured for deferred swap allocation
mode? I think our system was configured for immediate swap allocation.
My understanding of immediate swap mode is that it's the virtual process
size that drives swap space usage which made me suspicious when I saw the
differences in the VSZ column of the output from the ps command. Perhaps it
isn't as simple as I would like to think.
There were two points that I didn't make clear in the initial posting
(a common failing of mine - sorry):
1. In reality many users executing the same application. So, the kernel
freeing/not freeing VM when a process free()'s memory would make a real
difference on the amount of swap being used.
2. The swap space size wasn't modified by the upgrade from Tru64 3.2 to 4.0.
Hugh
Park, Byoung-Kyu <wanderer@unitel.co.kr> wrote in message
news:8uvnlp$8ek$1@news.nuri.net...
> Checking the swap area.
> => #swapon -s
>
> Program executing is memory load and allocation swap space.
> so, messages display that low swap space
> ex> recommand swap space = Physical memory * 2.5 or 3.0
>
>
> "root" <hugh.patrick@virgin.net> wrote in message
> news:3A11AFE6.194B9261@virgin.net...
> > This is a historic question.
> >
> > We upgraded from Tru64 3.2G to Tru64 4.0F some time ago. When we ran
> > our application on 4.0F we started getting "Low swap space" warnings
> > that we did not get under 3.2G.
> >
> > Looking at the VSIZE column of the 'ps' output I noticed that under 4.0F
> > memory allocated to a process is not released back to the operating
> > system - i.e. VSIZE only ever increases. Under 3.2G the
> > VSIZE fluctuates up and down.
> >
> > I wrote the following simple test C program:
> >
> > #include <stdio.h>
> > #include <stdlib.h>
> > #define MB (1024*1024)
> > void main(void)
> > {
> > char *mem_block1;
> > char *mem_block2;
> >
> > mem_block1 = (char *)malloc(50*MB);
> > mem_block2 = (char *)malloc(50*MB);
> > getchar(); /* give chance to run ps */
> > free(mem_block2);
> > get_char(); /* give chance to run ps */
> > }
> >
> > Under 4.0F the VSIZE is approx 100Mb + some process overhead
> > Under 3.2G the VSIZE is approx 50MB + some process overhead.
> >
> > Unfortunately I no longer have access to the 3.2G box.
> >
> > Does anyone know for certain if the memory management was changed from
> > 3.2, in which malloc()/free() off-loaded all memory management to the
> > kernel, and 4.0F which appears to expect the user processes to manage
> > free space with malloc()/free()? I'm guessing this change (if I'm
> > right) was made for kernel efficiency - for example, less scanning of
> > free lists, less swap allocation/deallocation activity, etc.
> >
> > Regards,
> > Hugh Patrick
> >
> >
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Memory Management
2000-11-17 2:07 ` Hugh Patrick
@ 2000-11-17 5:00 ` Robert Mulley
2000-11-17 5:00 ` Hugh Patrick
0 siblings, 1 reply; 9+ messages in thread
From: Robert Mulley @ 2000-11-17 5:00 UTC (permalink / raw)
Hugh,
I remember reading somewhere that, malloc/free combo only release memory back
into re-use by the program. ie you malloc 2 Gb of memory, then free it, it only
gets released back for further mallocs by the same program. I can't remember
where I saw that.
I just read something else, which says that it is designed this way for
application performance methods. As the memory once malloc'ed/free'ed is still
attached to the program future malloc's are much quicker, ie doesn't have to
request memory from the system, system reduce UBC size to allocate the memory to
the program etc... A possible workaround might be to use mmap and munmap for
large allocate large areas of memory, or use shared memory segments. Good luck.
Robert Mulley
Unix Admin
Hugh Patrick wrote:
> Does this assume that the system was configured for deferred swap allocation
> mode? I think our system was configured for immediate swap allocation.
>
> My understanding of immediate swap mode is that it's the virtual process
> size that drives swap space usage which made me suspicious when I saw the
> differences in the VSZ column of the output from the ps command. Perhaps it
> isn't as simple as I would like to think.
>
> There were two points that I didn't make clear in the initial posting
> (a common failing of mine - sorry):
> 1. In reality many users executing the same application. So, the kernel
> freeing/not freeing VM when a process free()'s memory would make a real
> difference on the amount of swap being used.
> 2. The swap space size wasn't modified by the upgrade from Tru64 3.2 to 4.0.
>
> Hugh
>
> Park, Byoung-Kyu <wanderer@unitel.co.kr> wrote in message
> news:8uvnlp$8ek$1@news.nuri.net...
> > Checking the swap area.
> > => #swapon -s
> >
> > Program executing is memory load and allocation swap space.
> > so, messages display that low swap space
> > ex> recommand swap space = Physical memory * 2.5 or 3.0
> >
> >
> > "root" <hugh.patrick@virgin.net> wrote in message
> > news:3A11AFE6.194B9261@virgin.net...
> > > This is a historic question.
> > >
> > > We upgraded from Tru64 3.2G to Tru64 4.0F some time ago. When we ran
> > > our application on 4.0F we started getting "Low swap space" warnings
> > > that we did not get under 3.2G.
> > >
> > > Looking at the VSIZE column of the 'ps' output I noticed that under 4.0F
> > > memory allocated to a process is not released back to the operating
> > > system - i.e. VSIZE only ever increases. Under 3.2G the
> > > VSIZE fluctuates up and down.
> > >
> > > I wrote the following simple test C program:
> > >
> > > #include <stdio.h>
> > > #include <stdlib.h>
> > > #define MB (1024*1024)
> > > void main(void)
> > > {
> > > char *mem_block1;
> > > char *mem_block2;
> > >
> > > mem_block1 = (char *)malloc(50*MB);
> > > mem_block2 = (char *)malloc(50*MB);
> > > getchar(); /* give chance to run ps */
> > > free(mem_block2);
> > > get_char(); /* give chance to run ps */
> > > }
> > >
> > > Under 4.0F the VSIZE is approx 100Mb + some process overhead
> > > Under 3.2G the VSIZE is approx 50MB + some process overhead.
> > >
> > > Unfortunately I no longer have access to the 3.2G box.
> > >
> > > Does anyone know for certain if the memory management was changed from
> > > 3.2, in which malloc()/free() off-loaded all memory management to the
> > > kernel, and 4.0F which appears to expect the user processes to manage
> > > free space with malloc()/free()? I'm guessing this change (if I'm
> > > right) was made for kernel efficiency - for example, less scanning of
> > > free lists, less swap allocation/deallocation activity, etc.
> > >
> > > Regards,
> > > Hugh Patrick
> > >
> > >
> >
> >
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Memory Management
2000-11-14 5:00 Memory Management root
2000-11-16 4:25 ` Park, Byoung-Kyu
@ 2000-11-17 5:00 ` Nikola Milutinovic
2000-11-18 5:00 ` Hugh Patrick
1 sibling, 1 reply; 9+ messages in thread
From: Nikola Milutinovic @ 2000-11-17 5:00 UTC (permalink / raw)
root wrote:
>
> This is a historic question.
>
> We upgraded from Tru64 3.2G to Tru64 4.0F some time ago. When we ran
> our application on 4.0F we started getting "Low swap space" warnings
> that we did not get under 3.2G.
>
> Looking at the VSIZE column of the 'ps' output I noticed that under 4.0F
> memory allocated to a process is not released back to the operating
> system - i.e. VSIZE only ever increases. Under 3.2G the
> VSIZE fluctuates up and down.
>
> I wrote the following simple test C program:
I have tested your C program on 4.0F and 4.0D - it shows the dreaded
behaviour, not freeing memory. Both 4.0D and 4.0F have the latest patch
kits.
I'm sending this to the mailing list, we should here from them rather
soon.
Nix.
--
True programmers never die, they just branch to an odd address.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Memory Management
2000-11-17 5:00 ` Robert Mulley
@ 2000-11-17 5:00 ` Hugh Patrick
0 siblings, 0 replies; 9+ messages in thread
From: Hugh Patrick @ 2000-11-17 5:00 UTC (permalink / raw)
Robert Mulley wrote:
> Hugh,
>
> I remember reading somewhere that, malloc/free combo only release memory back
> into re-use by the program. ie you malloc 2 Gb of memory, then free it, it only
> gets released back for further mallocs by the same program. I can't remember
> where I saw that.
>
> I just read something else, which says that it is designed this way for
> application performance methods. As the memory once malloc'ed/free'ed is still
> attached to the program future malloc's are much quicker, ie doesn't have to
> request memory from the system, system reduce UBC size to allocate the memory to
> the program etc... A possible workaround might be to use mmap and munmap for
> large allocate large areas of memory, or use shared memory segments. Good luck.
>
> Robert Mulley
> Unix Admin
>
> Hugh Patrick wrote:
>
> > Does this assume that the system was configured for deferred swap allocation
> > mode? I think our system was configured for immediate swap allocation.
> >
> > My understanding of immediate swap mode is that it's the virtual process
> > size that drives swap space usage which made me suspicious when I saw the
> > differences in the VSZ column of the output from the ps command. Perhaps it
> > isn't as simple as I would like to think.
> >
> > There were two points that I didn't make clear in the initial posting
> > (a common failing of mine - sorry):
> > 1. In reality many users executing the same application. So, the kernel
> > freeing/not freeing VM when a process free()'s memory would make a real
> > difference on the amount of swap being used.
> > 2. The swap space size wasn't modified by the upgrade from Tru64 3.2 to 4.0.
> >
> > Hugh
> >
> > Park, Byoung-Kyu <wanderer@unitel.co.kr> wrote in message
> > news:8uvnlp$8ek$1@news.nuri.net...
> > > Checking the swap area.
> > > => #swapon -s
> > >
> > > Program executing is memory load and allocation swap space.
> > > so, messages display that low swap space
> > > ex> recommand swap space = Physical memory * 2.5 or 3.0
> > >
> > >
> > > "root" <hugh.patrick@virgin.net> wrote in message
> > > news:3A11AFE6.194B9261@virgin.net...
> > > > This is a historic question.
> > > >
> > > > We upgraded from Tru64 3.2G to Tru64 4.0F some time ago. When we ran
> > > > our application on 4.0F we started getting "Low swap space" warnings
> > > > that we did not get under 3.2G.
> > > >
> > > > Looking at the VSIZE column of the 'ps' output I noticed that under 4.0F
> > > > memory allocated to a process is not released back to the operating
> > > > system - i.e. VSIZE only ever increases. Under 3.2G the
> > > > VSIZE fluctuates up and down.
> > > >
> > > > I wrote the following simple test C program:
> > > >
> > > > #include <stdio.h>
> > > > #include <stdlib.h>
> > > > #define MB (1024*1024)
> > > > void main(void)
> > > > {
> > > > char *mem_block1;
> > > > char *mem_block2;
> > > >
> > > > mem_block1 = (char *)malloc(50*MB);
> > > > mem_block2 = (char *)malloc(50*MB);
> > > > getchar(); /* give chance to run ps */
> > > > free(mem_block2);
> > > > get_char(); /* give chance to run ps */
> > > > }
> > > >
> > > > Under 4.0F the VSIZE is approx 100Mb + some process overhead
> > > > Under 3.2G the VSIZE is approx 50MB + some process overhead.
> > > >
> > > > Unfortunately I no longer have access to the 3.2G box.
> > > >
> > > > Does anyone know for certain if the memory management was changed from
> > > > 3.2, in which malloc()/free() off-loaded all memory management to the
> > > > kernel, and 4.0F which appears to expect the user processes to manage
> > > > free space with malloc()/free()? I'm guessing this change (if I'm
> > > > right) was made for kernel efficiency - for example, less scanning of
> > > > free lists, less swap allocation/deallocation activity, etc.
> > > >
> > > > Regards,
> > > > Hugh Patrick
> > > >
> > > >
> > >
> > >
Thanks Robert.
This certainly fits with what I've seen in the VSZ column of ps. It is also what
I generally seen on SysV derived Unix systems.
I realise that this is quite an esoteric question (probably more suited to the
kernel internals newsgroup). Do you happen to know if this behaviour was
introduced in 4.0? Alternatively, would you know of a good starting point - I've
had trouble finding in-depth Tru64 related info. on Compaq's web-site. I was
hoping to get the Tru64 internal data structures book that was advertised on Amazon
but seems to have been removed recently.
I think 4.0 was the initial version of Tru64 that Compaq was targetting as an
Internet Server platform. This is probably based on the OS theory that processes
are always growing, shrinking, growing, shrinking as infinitum. It would free the
OS to server other system calls and network I/O, rather than constantly scanning
lists that can potentially be very large.
Hugh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Memory Management
2000-11-17 5:00 ` Nikola Milutinovic
@ 2000-11-18 5:00 ` Hugh Patrick
0 siblings, 0 replies; 9+ messages in thread
From: Hugh Patrick @ 2000-11-18 5:00 UTC (permalink / raw)
Nikola Milutinovic wrote:
> root wrote:
> >
> > This is a historic question.
> >
> > We upgraded from Tru64 3.2G to Tru64 4.0F some time ago. When we ran
> > our application on 4.0F we started getting "Low swap space" warnings
> > that we did not get under 3.2G.
> >
> > Looking at the VSIZE column of the 'ps' output I noticed that under 4.0F
> > memory allocated to a process is not released back to the operating
> > system - i.e. VSIZE only ever increases. Under 3.2G the
> > VSIZE fluctuates up and down.
> >
> > I wrote the following simple test C program:
>
> I have tested your C program on 4.0F and 4.0D - it shows the dreaded
> behaviour, not freeing memory. Both 4.0D and 4.0F have the latest patch
> kits.
>
> I'm sending this to the mailing list, we should here from them rather
> soon.
>
> Nix.
> --
> True programmers never die, they just branch to an odd address.
Thanks. It's nice to know that it reproduces on the latest patch kits - we
tend not to patch our systems but work around problems for logistical reasons
(230 remote servers connected via ISDN).
^ permalink raw reply [flat|nested] 9+ messages in thread
* Memory management
@ 2002-05-08 6:33 Miha Andrejasic
2002-05-08 16:38 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
0 siblings, 1 reply; 9+ messages in thread
From: Miha Andrejasic @ 2002-05-08 6:33 UTC (permalink / raw)
Hello!
I have a question regarding memory on my computer. I have Digital PWS
433a with Tru64 5.1A. I also have 512MB of memory.
I am having some problems with one of my programs. When I start the
program, it checks for available memory. It says that it requires at
least 256MB of memory. When the sistem is fresh everything is OK. But
when I close the program and start it again it says that there is no
more than 140MB of memory left.
If I want to use program again I have to shutdown system and boot it up
again.
I was told that this is a problem with memory allocation and that this
allocated memory isn't freed after use or when the program closes.
Is there anything I can do to free memory with software so I won't have
to reboot time after time just to use this program?
Thanx for your help.
CCCao
--
Miha Andrejasic
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Memory management
2002-05-08 6:33 Memory management Miha Andrejasic
@ 2002-05-08 16:38 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
0 siblings, 0 replies; 9+ messages in thread
From: Alan Rollow - Dr. File System's Home for Wayward Inodes. @ 2002-05-08 16:38 UTC (permalink / raw)
In article <3CD8C6D5.E16B0FF2@ijs.si>, Miha Andrejasic <miha.andrejasic@ijs.si> writes:
>
>I have a question regarding memory on my computer. I have Digital PWS
>433a with Tru64 5.1A. I also have 512MB of memory.
>
>I am having some problems with one of my programs. When I start the
>program, it checks for available memory. It says that it requires at
>least 256MB of memory. When the sistem is fresh everything is OK. But
>when I close the program and start it again it says that there is no
>more than 140MB of memory left.
How is the program checking for the amount of memory "available"?
Most modern computer systems use demand paged virtual memory. The
amount of memory "available" is as large as you're willing to put
up with the system paging. There are maximums enforced by architecture,
system tuning parameters and available page/swap space, but within
these limits you can always get the however much virtual memory that
you want.
Programs can check for the amount of free memory. This isn't a
particularly reliable method for deciding that there is enough
memory to run, since you are on a demand paged virtual memory
system. Part of the problem using free memory as a guide is
that the file system buffer cache can use nearly all available
memory to cache file data. This tends to make free memory very
fluid. You may not a appear to have much at some moment, but as
soon your program needs pages, they can be reclaimed.
>If I want to use program again I have to shutdown system and boot it up
>again.
>I was told that this is a problem with memory allocation and that this
>allocated memory isn't freed after use or when the program closes.
The symtom as described of often called a "memory leak". Certain
applications have been known to have them, but any such problem
in the operating system would have been fixed long ago. The memory
allocation routine most commonly used by C programmers (malloc(3))
doesn't necessarily give virtual memory back to the system when
freed. However, if the program is freeing the memory, then it
will be available for later allocations. Some implementations can
give memory back under the right circumstance. I don't recall if
the Tru64 UNIX implementation is one of these.
>
>Is there anything I can do to free memory with software so I won't have
>to reboot time after time just to use this program?
As described, the problem you're having is not a problem that you
should be having. As long as there's enough page/swap space you
can always allocate more virtual memory. When the program exits,
whatever virtual memory it had allocated should be given back. So,
your program is doing something out of the ordinary.
There are lots of ways to allocate memory. At least one of them is
persistent. Is the program using shared memory? Is it memory
mapping files? Does it start some other process to keep the memory
around even after it exits? Is the program locking pages?
I think there is a lot of you haven't said about this application.
It may simply be that you don't know, but you should find out,
since what you're seeing isn't typical.
>
>Thanx for your help.
>
>CCCao
>--
>Miha Andrejasic
>
--
Alan Rollow alan@nabeth.cxo.cpqcorp.net (previously .dec.com)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2002-05-08 16:38 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-08 6:33 Memory management Miha Andrejasic
2002-05-08 16:38 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
-- strict thread matches above, loose matches on Subject: below --
2000-11-14 5:00 Memory Management root
2000-11-16 4:25 ` Park, Byoung-Kyu
2000-11-17 2:07 ` Hugh Patrick
2000-11-17 5:00 ` Robert Mulley
2000-11-17 5:00 ` Hugh Patrick
2000-11-17 5:00 ` Nikola Milutinovic
2000-11-18 5:00 ` Hugh Patrick
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox