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

Re: Memory Allocation



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