[Kstars-devel] more on memory usage

Mark Hollomon markhollomon at comcast.net
Fri Sep 5 21:56:20 CEST 2003


You're simply not going to be able to get meaningful data that way I'm afraid.

Memory requests by your code are actually fulfilled in a two step process. 
First, the C++ Runtime library request a large chunk of memory from the OS 
and adds it to the "heap". The heap is then chopped up into bits and some 
portion is returned to your code.

VmData is, essentially, the size of the heap _not_ the amount of memory in 
active use by the program.

Freeing space in your code only returns to the heap, not to the OS. So, if at 
startup kstars uses a lot of memory that is later freed (e.g a splash image), 
that will make it look like a large amount of memory is in use.

The additional memory used between the 4 star and 15 star case is _not_ the 
space needed for 11 stars.. it is the size chunk that the memory allocator 
asks for from the operating system.

Note also that because of memory fragmentation. The allocator may have to ask 
the OS for more memory even though space is available in the heap - but a 
continuous chunk large enough for the request may not be available.


On Friday 05 September 2003 13:44, Jason Harris wrote:
> Hello,
>
> The mystery continues.  I am attempting to get a more precise measurement
> of the memory usage by examining the file /proc/[kstars-pid]/status.  This
> file describes the memory usage in several ways:
>
> VmExe = the executable
> VmLib = libraries (?)
> VmRSS = includes shared libraries
> VmData = size of data used by program (this is what we need!)
> VmSize = the grand total
>
> With all 125,994 stars loaded, VmData = 97380 kB
> With 4 stars loaded (mag<0.0) VmData = 19420 kB
> With 15 stars loaded (mag < 1.0) VmData = 20292 kB
>
> We can compute the memory used per-star by looking at the differences of
> these three instances:
>
> 125,990 stars = (97380-19420) = 77960 kB --> 0.618 kB per star
> 11 stars = (20292 -  19420) = 872 kB --> 79 kB per star!!
>
> Something is wrong here.  I thought it must be the additional memory of the
> star names, but when I use an alternate version of the star catalog for
> hich names have been removed, VmData is 19368, which is only 52 kB less
> than before.  This implies that the names take about 13 kB per star, not
> even close to 79 kB.
>
> I am puzzled.
>
> BTW, I think someone mentioned it before, but I am noticing that loading
> additional stars by increasing the faint limit while the program is running
> does not currently work.  We will need to fix that by release.

-- 
Mark Hollomon



More information about the Kstars-devel mailing list