[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

allocate particular amount of memory to a ruby thread ?

Pokkai Dokkai

6/10/2008 11:46:00 AM

how to allocate particular amount of memory to a ruby thread or to a
ruby script?

for example suppose if i want to start a thread it should take 1 MB
memory only

Thread.start(memory=1024*1024*1024) do |t|

# some stuff here
end

is there anyway to do like this ?
--
Posted via http://www.ruby-....

3 Answers

Jano Svitok

6/10/2008 2:48:00 PM

0

On Tue, Jun 10, 2008 at 13:46, Pokkai Dokkai <bad_good_lion@yahoo.com> wrote:
> how to allocate particular amount of memory to a ruby thread or to a
> ruby script?
>
> for example suppose if i want to start a thread it should take 1 MB
> memory only
>
> Thread.start(memory=1024*1024*1024) do |t|
>
> # some stuff here
> end
>
> is there anyway to do like this ?

AFAIK, the memory is shared among threads, no matter whether system or ruby's.
The memory for the whole ruby process/script is allocated on demand,
with some initial amount.
This amount and growing ratio is compiled-in (at least for 1.8).

Robert Klemme

6/10/2008 6:10:00 PM

0

On 10.06.2008 16:48, Jano Svitok wrote:
> On Tue, Jun 10, 2008 at 13:46, Pokkai Dokkai <bad_good_lion@yahoo.com> wrote:
>> how to allocate particular amount of memory to a ruby thread or to a
>> ruby script?
>>
>> for example suppose if i want to start a thread it should take 1 MB
>> memory only
>>
>> Thread.start(memory=1024*1024*1024) do |t|
>>
>> # some stuff here
>> end
>>
>> is there anyway to do like this ?
>
> AFAIK, the memory is shared among threads, no matter whether system or ruby's.

Exactly. That's the whole point of threads.

> The memory for the whole ruby process/script is allocated on demand,
> with some initial amount.
> This amount and growing ratio is compiled-in (at least for 1.8).

And there is no way to limit it. It might be possible to limit on a per
process base (depending on OS, see "ulimit -a") but not on a per thread
base. And there might be a limit on the stack size. But it does not
make sense to limit memory allocated by a thread because the memory is
shared and can be used from any thread.

Kind regards

robert

Jano Svitok

6/11/2008 12:09:00 AM

0

On Tue, Jun 10, 2008 at 20:14, Robert Klemme <shortcutter@googlemail.com> wrote:
> On 10.06.2008 16:48, Jano Svitok wrote:
>>
>> On Tue, Jun 10, 2008 at 13:46, Pokkai Dokkai <bad_good_lion@yahoo.com>
>> wrote:
>>>
>>> how to allocate particular amount of memory to a ruby thread or to a
>>> ruby script?
>> AFAIK, the memory is shared among threads, no matter whether system or
>> ruby's.
>
> Exactly. That's the whole point of threads.
>
>> The memory for the whole ruby process/script is allocated on demand,
>
> And there is no way to limit it. It might be possible to limit on a per

Pokkai, what's your primary goal/problem? Why do you want to limit the memory?
Maybe there's a solution if you can look at the problem from another angle.

J.