View mode: basic / threaded / horizontal-split · Log in · Help
November 09, 2011
Is there a portable way to limit memory/cpu usage of a D application?
I would be satisfied with something like POSIX.1-2001 setrlimit() . Sure 
nothing prevents me from using setrlimit() in my D app, but perhaps it is 
something to think about a portable way of doing that.

One thing I like about my Java apps is that I can always specify (in the 
argument list) how much memory I want to allocate for them). Yes, it is a 
JVM specific thing, but perhaps a GC should have options to set at least the 
memory limit?

Kind regards
November 10, 2011
Re: Is there a portable way to limit memory/cpu usage of a D application?
Le 09/11/2011 18:12, Dejan Lekic a écrit :
> I would be satisfied with something like POSIX.1-2001 setrlimit() . Sure
> nothing prevents me from using setrlimit() in my D app, but perhaps it is
> something to think about a portable way of doing that.
>
> One thing I like about my Java apps is that I can always specify (in the
> argument list) how much memory I want to allocate for them). Yes, it is a
> JVM specific thing, but perhaps a GC should have options to set at least the
> memory limit?
>
> Kind regards

Well no, but you can ask the gc to collect and realease block to the 
system explicitely (and not like in Java, which you can only trigger 
collection for young object from code). So basically you can control how 
much memory your application is consuming.
November 29, 2012
Re: Is there a portable way to limit memory/cpu usage of a D application?
On Wednesday, 9 November 2011 at 17:13:14 UTC, Dejan Lekic wrote:
> Sure
> nothing prevents me from using setrlimit() in my D app, but 
> perhaps it is
> something to think about a portable way of doing that.

I know I'm over a year late coming in on this conversation, but 
how would you use setrlimit() in your D app at all?  I can't seem 
to figure out what the correct library is to include in my 
program to be able to call set/getrlimit in any manner.  Thanks!
November 29, 2012
Re: Is there a portable way to limit memory/cpu usage of a D application?
On Thursday, 29 November 2012 at 04:44:34 UTC, Mike Young wrote:
> On Wednesday, 9 November 2011 at 17:13:14 UTC, Dejan Lekic 
> wrote:
>> Sure
>> nothing prevents me from using setrlimit() in my D app, but 
>> perhaps it is
>> something to think about a portable way of doing that.
>
> I know I'm over a year late coming in on this conversation, but 
> how would you use setrlimit() in your D app at all?  I can't 
> seem to figure out what the correct library is to include in my 
> program to be able to call set/getrlimit in any manner.  Thanks!

Well, if it is not in the posix module, then you simply use it by 
declaring "extern(C) int setrlimit(int resource, const void* 
rlim);" or something similar if you define the rlimit struct 
somewhere.
Remember, you can call C functions from your D code anytime, 
anywhere.
Top | Discussion index | About this forum | D home