From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,46c4d6f8b5a1b798 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 27 Nov 2004 18:53:44 -0600 From: David Botton Newsgroups: comp.lang.ada Date: Sat, 27 Nov 2004 19:53:46 -0500 Message-ID: <2004112719534675249%david@bottoncom> References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: Memory management in games User-Agent: Unison/1.5.2 NNTP-Posting-Host: 66.176.74.83 X-Trace: sv3-0CyLvCXH0wj6lOwTTOB9FvOiKxmfDFQhADbjZ4PQjo4vQkMLBLzc97cZcPgWgpOh3l1VPEAupN+XaE8!sH3fMKACvFY9Lj6M2A90QnS4HzE6HKfGKVP6Y/u7jn+icUDtCH0or80EGcmupw== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.20 Xref: g2news1.google.com comp.lang.ada:6571 Date: 2004-11-27T19:53:46-05:00 List-Id: Please see these two articles in the advanced section of the AdaPower Source Code Treasury Memory Management with Storage Pools (Anh Vo) http://www.adapower.com/index.php?Command=Class&ClassID=Advanced&CID=222 Memory Management with Storage Pools - Update (Anh Vo) http://www.adapower.com/index.php?Command=Class&ClassID=Advanced&CID=223 You probably should look through the advanced section in general for other good ideas and practices. David botton On 2004-11-27 14:48:48 -0500, "Luke A. Guest" said: > Hi, > > Further to my posts in the game dev thread, I've decided to go back on my > original thoughts and do the game engine in Ada (I can always *cough* port > *cough* gnat *cough* ;-D). > > Now, one of my design requirements is that I *must* be able to see *all* > memory allocations and track them, this is so I can build in debugging > tools into my engine. I have just done this in C++ by overriding the > global new/delete operators and using macros to redefine > new/delete/mallo/free/calloc/etc. to point to my new memory management > class. These macros also pass the filename and line number from where the > memory was allocated. Also, this class keeps track of all allocations in a > list template. I currently just dump out the contents of the list on exit. > > So, I need to be able to do the same in Ada. Enter Storage Pools, ok, it's > not difficult to write a pool class, I've just written a simple one. But, > what a game engine requires is the ability to allocate a big block of > memory and then allocate other blocks from this, so it's like a > hierarchical pool system. > > e.g. Under Linux, I might allocated a block of memory to use for the > entire game (from a start up script), say 50Mb and this will be used for > this session > > e.g On a PS2 we have something more challenging, the underlying OS needs > some memory to load the game ELF and have some memory to use for it's own > data structures, so in the game I say, give me 25Mb for this session. > > Then from this pool, other pools/objects are allocated. So, I need a way > to override the default memory allocation method for everything, including > library routines. Can this be done portably? I know I can specify the > T'Storage_Pool for a type, will this work for libgnat.a types as well? > > I've seen that GNAT provides the System.Memory package, this isn't > standard, so should I just go out of my way and import the memory > allocation functions I require (malloc on Linux, memalign on PS2, etc.)? > > Also, what would be the best method of passing the function name where the > allocation call is, through to the allocator, so that I can show where an > allocation was made? I could use gnatprep I suppose, but obviously would > prefer to be portable. FYI, there will be two builds as memory allocation > tracking would not be in the final release mode build as it's extra > overhead. > > Thanks, > Luke.