[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Memory Allocation
- To: linuxgames@sunsite.dk
- Subject: Re: Memory Allocation
- From: Igor Cabral Corrêa <imortis@uol.com.br>
- Date: Wed, 1 May 2002 01:48:21 -0300
- Delivered-To: archiver@seul.org
- Delivered-To: mailing list linuxgames@sunsite.dk
- Delivery-Date: Wed, 01 May 2002 00:51:28 -0400
- In-Reply-To: <3CD0AD71.66C5A6E4@airmail.net>
- Mailing-List: contact linuxgames-help@sunsite.dk; run by ezmlm
- References: <7884.18452-32485-880727361-1020199003@seznam.cz> <02043021590601.00231@200191140086-dial-user-UOL> <3CD0AD71.66C5A6E4@airmail.net>
- Reply-To: linuxgames@sunsite.dk
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