Memory Manager, STL, RTTI etc.
by Kaya Dogan · in Torque Game Engine Advanced · 09/02/2006 (2:33 am) · 9 replies
We have an issue here. After understanding how the TSE memory manager works/why it's there, we decided not to disable it. But now we ran into some trouble. It seems that none of the following things work with the memory manager enabled:
- STL
- Container Classes
- Standard C++ stuff (e.g. string)
- RTTI
We need all of the above in our current project. Now does anyone know how to make that stuff work w/ the TSE memory manager? The core issue we ran into when using the string-class for example was the redefinition of 'new' which of course is used to allocate and HOLD the required amount memory for TSE. Freeing and re-allocating memory all the time leads to performance issues.
- STL
- Container Classes
- Standard C++ stuff (e.g. string)
- RTTI
We need all of the above in our current project. Now does anyone know how to make that stuff work w/ the TSE memory manager? The core issue we ran into when using the string-class for example was the redefinition of 'new' which of course is used to allocate and HOLD the required amount memory for TSE. Freeing and re-allocating memory all the time leads to performance issues.
#2
If you decide to keep the Torque Memory Manager then you may want to look at Pete Isensee papers on custom STL allocators. It might be useful to setup the STL allocators to use the Torque Memory Manager.
09/02/2006 (1:56 pm)
First idea... disable the Torque Memory Manager... everything should work, but only as optimally as the native memory manager functions.If you decide to keep the Torque Memory Manager then you may want to look at Pete Isensee papers on custom STL allocators. It might be useful to setup the STL allocators to use the Torque Memory Manager.
#3
or I get errors (c2833 and c2059). Looks like we cannot use the string-class at this point. However other stuff might work (haven't tested that yet, cause at first I need to get the standard C++ lib to work here). Wish I was a C++ expert *lol* But anyway the above replies seem to be a great help for STL in general. Thx for that :) If anyone has an idea how to get the C++ standard header stuff to work smoothly, let me know...
09/03/2006 (3:46 am)
Hmm...I edited the required sources as described in the STL resource. But when I include
#4
09/15/2006 (5:06 am)
I tried the STL fix etc. but it doesn't work at all...what I get now is a link error about the operator new being redefined etc. I included the string headerfile and vector but both attempts ended up with such an error...
#5
09/15/2006 (5:14 am)
Edit: Nvm, the OP didnt want to disable the memory manager.
#6
09/15/2006 (5:43 am)
Wouldn't that destroy the memory manager?
#7
You'll have to decide which one you want. Because getting both to work together nicely will be fairly difficult, if not impossible. STL shouldn't be redefining new, shame on them.
Another alternative, if you want to do a bunch of busy work, is to change our redefine of new to a different name, like tnew for instance.
09/15/2006 (10:48 am)
I'm obviously biased, but I think what the memory manager gives you, in terms of utility to working with Torque, versus STL is far more valueable, I lump string in there too.You'll have to decide which one you want. Because getting both to work together nicely will be fairly difficult, if not impossible. STL shouldn't be redefining new, shame on them.
Another alternative, if you want to do a bunch of busy work, is to change our redefine of new to a different name, like tnew for instance.
#8
09/15/2006 (11:09 am)
@Kaya - Did you follow the full instructions in the stl_fix resource? There are changes to platform/platform.h and platform/platformMemory.cc that must be made as well. If i get time i'll try it again and see if i can fix it to work.
#9
I might even go down the tnew route at some point. As currently we have the torque mem manager disabled but I'd like to use it.
Dunno what to do for the best in this case though.
09/17/2006 (7:07 am)
Rob: I have to disagree there. STL and things that use it a FAR more common (especially when you want to use third party libs for example) than you might think. So having a way to get torque to "play nice" with one of the most widely used tools of a C++ programmer is a win in my book.I might even go down the tnew route at some point. As currently we have the torque mem manager disabled but I'd like to use it.
Dunno what to do for the best in this case though.
Torque Owner Johan Carlsson
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7480