Advertisement

Memory Usage and Memory Counter

Started by July 10, 2012 01:27 AM
1 comment, last by saejox 12 years, 5 months ago
Hi,

i am trying to determine how much memory scripts use.
i have overridden free and malloc with asSetGlobalMemoryFunctions.
used map<void*, size_t> for sizes.

all is well.
for objects declared in script and primitives at least.

without registered types, this counter is pretty much useless, most used types are registered stuff; Vector3, Quaternion, Degree etc...

now do i need to modify every registered object's constructors and destructor?
(including addons i think)

what about PODs, most of them dont even have destructors.

to be concise, for what type of objects my custom free/malloc will be called?

Thanks.
The custom memory functions are used for all memory that the script engine is allocating. This includes memory needed to store the registered interface, bytecode, the contexts and its stack, script classes, all value types, etc.

Reference types allocate their own memory, so unless you change the factory to allocate that memory from the same custom memory functions they are not counted. If you're using the add-ons you'll also have to look into the internal memory allocated, for example the buffer used by std::string, the buffer used by the array, etc.

Your own registered types are likely also allocating internal memory buffers, so you'll have to analyse those as well.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
i will do my own memory counting for objects created in c++ then.
i kinda hate malloc and free. there are nasty and dirty.

thanks.

This topic is closed to new replies.

Advertisement