Memory use question

When I run a program, with these objects, it uses around 15-20MB of RAM,
thus:

VmPeak: 34308 kB
VmSize: 31312 kB
VmLck: 0 kB
VmHWM: 18808 kB
VmRSS: 16144 kB
VmData: 21224 kB
VmStk: 120 kB
VmExe: 4 kB
VmLib: 9320 kB
VmPTE: 36 kB
Threads: 2

String 8620
Class 737
Regexp 410
Array 327
Float 312
Proc 146
Range 116

Where Strings are around 2K chars each (I assume 2KB of memory, of
course that’s what I’m trying to figure out). So I am scratching my
head wondering if 34MB of RAM is normal for this type of load or not.
Any thoughts?
-Roger

On Sep 24, 2007, at 3:57 PM, Roger P. wrote:

VmStk: 120 kB
Proc 146

Why wouldn’t it be?
If you are loading objects into memory and keeping them in use, then
memory will bloat.
In garbage collected languages, even though memory management is
technically done for you, the way you write a program still makes it
bloat or not. But if you’re wondering, most new systems sold today
ship with 1gb of RAM. The OS will generally use all of it that it can
use and keep some for swapping things in and out in memory.

Garbage Collection is not as sophisticated as the OS’s memory
management for sure!
I’m not claiming to be an elite expert or anything, but the way you
manage objects even with GC will still determine how big of a
footprint an app tries to claim.
If you’re processing lots of data, you can definitely expect a bigger
load, but it all depends on how much you try to process at once and
what you try to do with it. I see you’re using RegExes, and greedy
RegExes can be big bloaters. But for the same reasons that simply
loading an entire big text file into objects (one for each line,
often) can be a big drain too. If you don’t know how big they are,
or the data source is, you should be limiting it by only reading the
source of data X number of bytes at a time.

Maybe you already are, but if you’re not, you need to manage the flow
of data in (and out) of the program.

Airports can’t process all the passengers at once, so they queue
them. If planes stop leaving, then people have to stop entering the
terminals or it will get too crowded to function!

John J. wrote:

On Sep 24, 2007, at 3:57 PM, Roger P. wrote:

VmStk: 120 kB
Proc 146

Why wouldn’t it be?

Maybe you already are, but if you’re not, you need to manage the flow
of data in (and out) of the program.

Yeah I think the problem is that I have the file incoming (a string),
write it to disk, then read it from disk again. So lots of random
strings kicking around. Maybe GC.start will help me :slight_smile:
Thank you!
-Roger

On Sep 25, 2007, at 10:00 AM, Roger P. wrote:

of data in (and out) of the program.

Yeah I think the problem is that I have the file incoming (a string),
write it to disk, then read it from disk again. So lots of random
strings kicking around. Maybe GC.start will help me :slight_smile:
Thank you!
-Roger

Posted via http://www.ruby-forum.com/.

Handle the data in pieces whenever possible. Take smaller bites. It
may make things slower for very very small files/ data sets, but it
will be more stable over larger ones.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs