[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Writing long-running daemons without memory leaks?

Toby DiPasquale

3/17/2006 3:37:00 PM

Hi all,

I am in the middle of writing some code that will exist as a
long-running process on a number of machines. I am having trouble
keeping memory utilization down, which is important in this case,
because other processes on these machines will have priority to use the
majority of RAM on these boxes for other tasks. The daemon itself is
pretty simple, just reading and writing files and keeping some small
state, but it also needs to cache large writes from multiple clients.
When it does this, I find that this memory is not freed.

My question is, I've heard from numerous accounts that WEBrick also
leaks memory, and I would suspect that Mongrel does, too (though I
haven't confirmed that) for the same reason. I understand that Ruby's GC
is conservative, but can anyone point me to documentation, reference,
source code, anything really that will help me better understand how to
write Ruby code that doesn't "leak" and can be sustained as a
long-running process without an ever-increasing memory footprint?

Any help would be greatly appreciated. Thanks in advance.

P.S. I've read the Pickaxe's lone page on the subject (in the Duck
Typing chapter) and I've seen Why's article about the same
(http://whytheluckystiff.net/articles/theFullyUpturn...).

P.P.S. Has Minero Aoki's Ruby book been translated to English anywhere?
I hear that it has a whole chapter on GC...

--
Toby DiPasquale

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


8 Answers

Ara.T.Howard

3/17/2006 3:48:00 PM

0

Ara.T.Howard

3/17/2006 5:25:00 PM

0

Toby DiPasquale

3/17/2006 5:45:00 PM

0

unknown wrote:
> harp:~ > ps aux|head -1; while true;do ruby b.rb && ps aux|grep
[...]
> ahoward 13671 18.3 19.5 212736 200952 pts/26 R 10:14 1:12 ruby
> a.rb
> ahoward 13671 18.4 21.1 230824 216768 pts/26 R 10:14 1:12 ruby
> a.rb
> ahoward 13671 18.5 22.3 230816 229404 pts/26 S 10:14 1:12 ruby
> a.rb
>
>
> so memory builds to about 25 and, presumably when the gc kicks in, drops
> to 15
> - but it certainly stays in this range.
>
> what os and ruby version?

ruby 1.8.4 on Ubuntu Linux, kernel 2.6.12-10 on a P4 Thinkpad with 1GB
RAM. The other systems having this problem are all also running Linux
2.6.x with ruby 1.8.4.

One thing about the above: you do realize that's ~250MB and ~150MB, not
25 and 15, right?

--
Toby DiPasquale

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


Booker C. Bense

3/17/2006 9:29:00 PM

0

-----BEGIN PGP SIGNED MESSAGE-----

In article <7d20c3f1c9ff08ff73faab5feefc8eb2@ruby-forum.com>,
Toby DiPasquale <toby@cbcg.net> wrote:
>Hi all,
>
>I am in the middle of writing some code that will exist as a
>long-running process on a number of machines. I am having trouble
>keeping memory utilization down, which is important in this case,
>because other processes on these machines will have priority to use the
>majority of RAM on these boxes for other tasks. The daemon itself is
>pretty simple, just reading and writing files and keeping some small
>state, but it also needs to cache large writes from multiple clients.
>When it does this, I find that this memory is not freed.
>

_ This is generally true of all unix processes. They do not
return allocated memory back to the system until they exit.
Freeing memory inside the code merely allows you to use it
again, it does not make it available to the system.

_ If your process is not using the memory, it may stay swapped
out, ( look at the real and virtual sizes ). If this is really
an issue, the standard way around it is to do the memory
intensive part in a forked subprocess that exits after it's
done.

_ Booker C. Bense


-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBRBsqMGTWTAjn5N/lAQHVbwP/XYqiyZsWzCqsYNfzP4rCe5cEzWbKBBfU
54A/x/DDnImzpM3MYcIG4Um2AAGFBYMrylxEeTv0Ot6RMi7Nl2NJLIzIg/6lGh1M
6d1ojbnddmUGfJXuYDZ2/lcWDWYzYCM6hYbWGh7h6eMYtNVZizE1k9ebA4zL+H0i
jFU8K8Aoe7k=
=ZbII
-----END PGP SIGNATURE-----

Jokho Nyingkir

9/7/2010 6:45:00 PM

0

Moorthy <mortayee@hotmail.co.uk> wrote in news:30859f61-c6fb-4d1c-a97f-
d7c0f37c9ee4@t20g2000yqa.googlegroups.com:

>
> This burning of books, places of worship and learning is old Islamic
> pastime across the globe strated with burning of oldest University
> Nalananda in India and has continued across ages, the recent memorable
> event being of Satanic verses. So why so much fuss about Koran? I
> personally would expose the concocted death manual rather than
> creating pollution.
>
>

would you rather see they eat and
swallow their own poisson they feed the world ?!

**) I understand Arab government confiscates Bible and Torah !

uNmaivirumbi

9/7/2010 6:46:00 PM

0

On Sep 7, 1:52 pm, Moorthy <morta...@hotmail.co.uk> wrote:
> This burning of books, places of worship and learning is old Islamic
> pastime across the globe strated with burning of oldest University
> Nalananda in India and has continued across ages, the recent memorable
> event being  of Satanic verses. So why so much fuss about Koran? I
> personally would expose the concocted death manual rather than
> creating pollution.

Agreed!

habshi

9/7/2010 10:18:00 PM

0

If Mein Kampf was burn would it create such an outcry?
Why then when the book calls for killing unbelivers ? verse 9.5,
8.39 etc

uNmaivirumbi

9/8/2010 12:38:00 AM

0

On Sep 7, 6:18 pm, hab...@anony.net wrote:
>       If Mein Kampf was burn would it create such an outcry?
>    Why then when the book calls for killing unbelivers ? verse 9.5,
> 8.39 etc

This Jones fellow is such a poor speaker. He does not say anything to
support burning. The simple fact is Koran is pure evil. Verses
indicate rape, murder!

Koran should be exposed but burning sends message fast but get beyond
burning later