[Gambas-user] what determines an application's resource useage

Benoit Minisini gambas at ...1...
Fri Apr 25 21:13:19 CEST 2008


On vendredi 25 avril 2008, Ron Onstenk wrote:
> On Thursday 24 April 2008 22:14, Benoit Minisini wrote:
> > On jeudi 24 avril 2008, M0E Lnx wrote:
> > > This question has been going around in my head for quite a while and
> > > I'd like to get an answer.
> > >
> > > How can I make sure that my application doesn't consume too much of
> > > the system resources?
> > > It is my understanding (correct me if I'm wrong) that if I assign a
> > > variable in an application, the system will allocate a certain ammount
> > > of RAM to that one variable (Ammount depends on the type of variable
> > > that is declared)
> >
> > No, assigning a variable does not use memory at all.
> >
> > Memory is allocated when:
> >
> > - A class is loaded.
> >
> > - A new object is created.
> >
> > The variables in the stack are allocated at startup.
> >
> > And of course, the libraries used by Gambas allocates memory on their
> > own.
> >
> > Regards,
>
> uuum
>
> Variables should use memory. but the difference here is the space is not
> used in the runtime resident allocated memory space but the stack.
>
> However do not put to much on that stack space. It is not size of your free
> memory (1Gibyte Dram inserted) but a limitted memory stack space.
> Creating dynamic 100000 variables/objects wil hurt that stack.
>
> Stack is also memory so the answer in reality is 'yes' but a more
> efficent way and the resident (fixed) menory footprint stays small.
>
> Ron
>

We are not talking about the stack used by the interpreter process, but the 
Gambas stack used by the interpreted bytecode.

This stack is allocated at startup, and cannot grow at the moment. So the 
number of local variables declared in a function changes nothing about used 
memory, unless you have recursive functions of course.

Regards,

-- 
Benoit Minisini




More information about the User mailing list