ubuntu jaunty seized up

Smoot Carl-Mitchell smoot at tic.com
Mon May 4 19:42:26 UTC 2009


On Mon, 2009-05-04 at 12:24 -0700, prad wrote:
> On Mon, 04 May 2009 12:30:34 -0600
> "Karl F. Larsen" <klarsen1 at gmail.com> wrote:
> 
> > Observe top is just below Xorg and above compiz.real. This is a lot
> > of use of both RAM and CPU time for a simple program.
> >
> i find it is fluctuating a fair bit, but always at the low end of the
> list with cpu=.3 mem=.3 most of the time though the cpu occasionally
> goes up to .7, may be when it samples?
> 
> what exactly is a memory leak and its effect?
> does it mean a program is using memory that hasn't been allocated to it?
> or is it that a program is losing info and has to keep going back to
> get it from the hd?
> if the former, wouldn't that explain to some extent why memory usage
> shows up as being high?

A memory leak is where a program continues to allocate memory without
returning unused memory back to the system.  The symptoms will be a
continuous increase in the size of the program.  A simple program with a
memory leak would be something like:

#! /usr/bin/perl -w

# Array grows without bound (slowly)

my @x = ();

my $i = 0;

while (1) {
	sleep 1;
	$x[$i] = $i;
}

The array "x" will grow without bound.  You will see the size of the
program grow slowly over time until it consumes all the memory or
exceeds its memory resource limits.  This one grows *very* slowly, since
it is pausing for 1 second each time through the infinite loop.

Real memory leakers are more complicated than this one and usually are
the result of sloppy programming.  Most modern languages like Java or
Ruby or even Perl have built in garbage collectors which return unused
memory back to the free pool.  These garbage collectors eliminate a lot
of memory leaking problems on long running programs.
-- 
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list