Find a memory leak

Hi,

i’ve got a script which do something like that:

for i in 0…NB_THREAD
th < Thread.new(i) { |nb|
while site[nb] = pop.liste do
check(site[nb])
end
}
end

for i in 0…NB_THREAD
th[i].join
end

The scrit run several minutes (liste is huge), and the memory consumption
increase a lot during execution.
So i have to find which object is growing up.
How can i do that ? (ie find the size of all object used)

Regards

Hi,

i’ve got a script which do something like that:

for i in 0…NB_THREAD
th < Thread.new(i) { |nb|
while site[nb] = pop.liste do
check(site[nb])
end
}
end

I don’t know what ‘pop’ is in this context, but is its accessor
thread safe? Have you got a Mutex around it so that only one thread
fiddles with it at once? Similarly for the site array. I suspect
that could do odd things to memory.

for i in 0…NB_THREAD
th[i].join
end

The scrit run several minutes (liste is huge), and the memory consumption

Should that be liste.pop then?

increase a lot during execution.

Depending on what check does with this data, I’d expect lots of
memory to be used, then.

So i have to find which object is growing up.
How can i do that ? (ie find the size of all object used)

Not sure about that.

Regards

    Hugh
···

On Wed, 5 Mar 2003, Cedric Foll wrote:

Hi,

···

At Wed, 5 Mar 2003 22:39:20 +0900, Cedric Foll wrote:

The scrit run several minutes (liste is huge), and the memory consumption
increase a lot during execution.
So i have to find which object is growing up.
How can i do that ? (ie find the size of all object used)

Objects referred from a thread never be freed until the thread
get freed. You need to discard references to threads after
join.


Nobu Nakada

for i in 0…NB_THREAD
th < Thread.new(i) { |nb|
while site[nb] = liste.pop do
check(site[nb])
end
}
end

(liste.pop and not pop.liste)

“Cedric Foll” cedric.foll@ac-rouen.fr schrieb im Newsbeitrag
news:pan.2003.03.05.14.11.31.701089@ac-rouen.fr

for i in 0…NB_THREAD
th < Thread.new(i) { |nb|

Do you mean this?
th << Thread.new …

while site[nb] = liste.pop do
check(site[nb])
end
}
end

You might want to use the Queue from
http://www.rubygarden.org/ruby?MultiThreading as replacement for “liste” in
order to thread safe access those items in “liste”.

Regards

robert