[WriteLog] Software Memory Leak
Rick Commo
Rick.Commo@verizon.net
Wed, 2 Jan 2002 23:12:41 -0800
This is a multi-part message in MIME format.
------=_NextPart_000_0029_01C193E2.FA2623A0
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: 7bit
What Len is saying is quite true. And you have to consider that Win2K with
Win9x/ME are all "virtual memory" operating systems.
Time for a 20,000 foot view of virtual memory..
What does "virtual" mean? Nothing more than the fact that when RAM is about
to be used up the OS will take some that hasn't been used in a while and
write it out to the "swap file". This frees up that chuck of RAM to be used
by an active program (process actually). The part of the OS called the
"memory manager", along with some help from the hardware can make any
section of RAM appear at any address within the 4GB range represented by a
32 bit address. So if your hard disk is big enough to afford a 4GB swap
file then you can have a full 32 bits of "virtual" memory in use at once.
Even if your machine only has, say 128MB. Having said that, let's make it
perfectly clear that this would be a *very* ridiculous set-up. But in
theory it's possible.
Let's look at the problem on a more practical note. Let's say that you
have 128MB along with a 256MB page file. As the 128MB or real, physical
memory is used up sections that haven't been used in a while will get
"swapped out" (written) to the page file and the newly freed up RAM is put
back into the service of a different process or program. As a rule of
thumb, try to have as much RAM as you can afford and make the swap file the
same size or twice as large.
If your disk often sounds like a popcorn machine then your computer is
really hitting the swap file hard and you need more RAM. Incidentally,
there is a range of opinion as to what the ratio of swap file size to RAM
size should be. I use 2:1, mostly because that was a recommended practice
that I read about somewhere. Others can make good arguments to move the
ratio up or down. If you are using up what virtual memory that you have (in
our example, 384MB) then you might be able to delay the agony by increasing
the size of the swap file - but it will cost you in performance. RAM is
orders of magnitude faster than disk!
With 128MB on a machine running Win2K Server, I often heard the disk
swapping. I might just do something as simple as activate a window in the
background that I haven't used in a while. I would often be subjected to
2/5/10 seconds of "popcorn popping" later before the window would finally
pop up. I increased the RAM to 512MB when prices were cheap. Now I rarely
hear the disk swapping. And things seem a lot faster.
Now back to WriteLog. WriteLog would probably have to be working one one
*huge* log to push the limits of a reasonably set up machine. What *is*
more poisonous is what Len talked about.
Imagine a program that asks for a chunk of memory as part of an operation;
and that this operation is done over and over again. The chunk of memory
was only meant to be used temporarily, but the programmer forgot to release
it in some other part of the program. Bingo, you've got a memory leak.
Over time this *can* eat up your RAM and swap file. This is where Perfmon,
the NT/WIn2K/WinXP performance monitor, can help you track memory usage.
Hope this hasn't been too boring for folks.
Cheers,
-ricK7log
-----Original Message-----
From: writelog-admin@contesting.com
[mailto:writelog-admin@contesting.com]On Behalf Of Len Umina
Sent: Wednesday, January 02, 2002 6:09 PM
To: N5MT@aol.com; jflanders2@home.com
Cc: writelog@contesting.com
Subject: RE: [WriteLog] Software Memory Leak
Mike,
It's not the fact that the program uses or reserves more than need or that
it keeps everything in memory to make the program run faster that causes the
leak.
The leak is caused by the programmer or the operating system inadvertently
forgetting to free up the memory that was reserved or used by the program.
73, Len K1LU (a experienced memory leaker)
-----Original Message-----
From: writelog-admin@contesting.com
[mailto:writelog-admin@contesting.com]On Behalf Of N5MT@aol.com
Sent: Wednesday, January 02, 2002 3:58 PM
To: jflanders2@home.com
Cc: writelog@contesting.com
Subject: [WriteLog] Software Memory Leak
A memory leak occurs when there is a logic bug in an application pgm
that actually uses more memory than needed (bug in the logic) and eventually
you run out of real and virtual memory from the OSystem. Like when a loging
program keeps everything in memory to make access faster.
There was a fix by Microsoft for at least for one leak in Windows NT
back 2-3 yrs ago. But apps do their own thing most times. There does not
have to be a cpu loop to create a memory leak by an application, it is
usually a logic pblm trying to keep too much in memory at one time. When I
am using Win2K , I can see exactly what is being used by program with the
Windows Task Manager and all the system tasks.
73 Mike N5MT
------=_NextPart_000_0029_01C193E2.FA2623A0
Content-Type: text/html;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>What=20
Len is saying is quite true. And you have to consider that Win2K =
with=20
Win9x/ME are all "virtual memory" operating=20
systems.</FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>Time=20
for a 20,000 foot view of virtual memory.. </FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>What=20
does "virtual" mean? Nothing more than the fact that when RAM =
is=20
about to be used up the OS will take some that hasn't been used in a =
while and=20
write it out to the "swap file". This frees up that chuck of RAM =
to be=20
used by an active program (process actually). The part of the OS =
called the=20
"memory manager", along with some help from the hardware can make any =
section of=20
RAM appear at any address within the 4GB range represented by a 32 bit=20
address. So if your hard disk</FONT></SPAN><SPAN=20
class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2> is big=20
enough to afford a 4GB swap file then you can have a full 32 bits of =
"virtual"=20
memory in use at once. Even if your machine only has, say=20
128MB. Having said that, let's make it perfectly clear that =
this=20
would be a *very* ridiculous set-up. But in theory it's=20
possible.</FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>Let's=20
look at the problem on a more practical note. Let's say =
that=20
you have 128MB along with a 256MB page file. As the 128MB or real, =
physical memory is used up sections that haven't been used in a while =
will get=20
"swapped out" (written) to the page file and the newly freed up RAM is =
put back=20
into the service of a different process or program. As a =
rule of=20
thumb, try to have as much RAM as you can afford and make the swap file =
the same=20
size or twice as large. </FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>If=20
your disk often sounds like a popcorn machine then your computer is =
really=20
hitting the swap file hard and you need more RAM. Incidentally, =
there is a=20
range of opinion as to what the ratio of swap file size to RAM size =
should=20
be. I use 2:1, mostly because that was a recommended practice that =
I read=20
about somewhere. Others can make good arguments to move the ratio =
up or=20
down. If you are using up what virtual memory that you have (in =
our=20
example, 384MB) then you might be able to delay the agony by increasing =
the size=20
of the swap file - but it will cost you in performance. RAM is =
orders of=20
magnitude faster than disk! </FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>With=20
128MB on a machine running Win2K Server, I often heard the =
disk=20
swapping. I might just do something as simple =
as activate a=20
window in the background that I haven't used in a while. I would =
often be=20
subjected to 2/5/10 seconds of "popcorn popping" later before=20
the window would finally pop up. I increased the RAM to 512MB =
when=20
prices were cheap. Now I rarely hear the disk swapping. And =
things=20
seem a lot faster.</FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>Now=20
back to WriteLog. WriteLog would probably have to be working =
one one=20
*huge* log to push the limits of a reasonably set up machine. What =
*is*=20
more poisonous is what Len talked about. </FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>Imagine a program that asks for a chunk of memory as part of an =
operation; and that this operation is done over and over again. =
The chunk=20
of memory was only meant to be used temporarily, but the programmer =
forgot to=20
release it in some other part of the program. Bingo, you've got a =
memory=20
leak. Over time this *can* eat up your RAM and swap file. =
This is=20
where Perfmon, the NT/WIn2K/WinXP performance monitor, can help you =
track memory=20
usage.</FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>Hope=20
this hasn't been too boring for folks.</FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>Cheers,</FONT></SPAN></DIV>
<DIV><SPAN class=3D070274206-03012002><FONT face=3DArial color=3D#0000ff =
size=3D2>-ricK7log</FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
<DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
size=3D2>-----Original Message-----<BR><B>From:</B>=20
writelog-admin@contesting.com =
[mailto:writelog-admin@contesting.com]<B>On=20
Behalf Of </B>Len Umina<BR><B>Sent:</B> Wednesday, January 02, 2002 =
6:09=20
PM<BR><B>To:</B> N5MT@aol.com; jflanders2@home.com<BR><B>Cc:</B>=20
writelog@contesting.com<BR><B>Subject:</B> RE: [WriteLog] Software =
Memory=20
Leak<BR><BR></FONT></DIV>
<DIV><SPAN class=3D234250102-03012002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>Mike,</FONT></SPAN></DIV>
<DIV><SPAN class=3D234250102-03012002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234250102-03012002><FONT face=3DArial =
color=3D#0000ff size=3D2>It's=20
not the fact that the program uses or reserves more than need or that =
it keeps=20
everything in memory to make the program run faster that causes the=20
leak.</FONT></SPAN></DIV>
<DIV><SPAN class=3D234250102-03012002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234250102-03012002><FONT face=3DArial =
color=3D#0000ff size=3D2>The=20
leak is caused by the programmer or the operating system inadvertently =
forgetting to free up the memory that was reserved or used by the=20
program.</FONT></SPAN></DIV>
<DIV><SPAN class=3D234250102-03012002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234250102-03012002><FONT face=3DArial =
color=3D#0000ff size=3D2>73,=20
Len K1LU (a experienced memory leaker)</FONT></SPAN></DIV>
<BLOCKQUOTE>
<DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
size=3D2>-----Original Message-----<BR><B>From:</B>=20
writelog-admin@contesting.com =
[mailto:writelog-admin@contesting.com]<B>On=20
Behalf Of </B>N5MT@aol.com<BR><B>Sent:</B> Wednesday, January 02, =
2002 3:58=20
PM<BR><B>To:</B> jflanders2@home.com<BR><B>Cc:</B>=20
writelog@contesting.com<BR><B>Subject:</B> [WriteLog] Software =
Memory=20
Leak<BR><BR></FONT></DIV><FONT face=3Darial,helvetica><FONT lang=3D0 =
face=3DArial=20
size=3D2 FAMILY=3D"SANSSERIF">A memory leak occurs when there is a =
logic bug in=20
an application pgm that actually uses more memory than needed (bug =
in the=20
logic) and eventually you run out of real and virtual memory from =
the=20
OSystem. Like when a loging program keeps everything in memory =
to make=20
access faster.<BR><BR>There was a fix by Microsoft for at least for =
one leak=20
in Windows NT back 2-3 yrs ago. But apps do their own thing =
most=20
times. There does not have to be a cpu loop to create a memory =
leak by=20
an application, it is usually a logic pblm trying to keep too much =
in memory=20
at one time. When I am using Win2K , I can see exactly what is =
being=20
used by program with the Windows Task Manager and all the system =
tasks.=20
<BR><BR>73 Mike N5MT =20
</FONT></FONT></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0029_01C193E2.FA2623A0--