[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Allocation



On Thursday 02 May 2002 00:07, you wrote:
> Igor Cabral Corr?a wrote:
> > I'm not making a game now, but I thinking something related with game
> > creation. Maybe you could aid me, please...
> > If I declare all variables of my program global, giving to the OS the
> > task of managing virtual/phisical memory for these variables, I have
> > significant loss of speed than when I manage the blocks of memory with
> > malloc?
>
> It doesn't matter whether your variables are global, local or dynamically
> allocated onto the heap - Linux will manage them for you in *exactly* the
> same way.
>
> Like I said before - "Just don't worry about it."
>
> Otherwise, you might get a *tiny* speed advantage by using globals - but
> the ugliness that this induces into your code design isn't worth it.
>
> ----------------------------- Steve Baker -------------------------------
> Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
> URLs : http://www.sjbaker.org
>        http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
>        http://prettypoly.sf.net http://freeglut.sf.net
>        http://toobular.sf.net   http://lodestone.sf.net


I'll be honest with you: I thought in this question about memory allocation 
when working on my first scientific initiation project, a Matlab-to-C GPL 
compiler. Maybe this tiny speed advantage you said can be interesting in the 
target code of my compiler. It's commom the manipulation of matrices of order 
> 1000. In a program with lots of 1.000.000 iterations loops, the minimal 
speed advantage can make a great diference at the end.

I think this mailing list isn't for this kind of questions, but if necessary, 
can I ask some questions about compiler tools here? Flex and yacc has many 
aplications in game scripting too.


Thanks a lot!
Igor C. Corrêa - UFRJ - Brazil