Angelscript 2.7.0 leaks?

Started by
9 comments, last by GameDev.net 17 years, 6 months ago
I've been playing around with AS a bit and I seem to get a memory leak. I'm using "crtdbg.h" to detect the leak. I have checked that the scriptengine object is released properly and that no other part of my code is causing it. I don't know if AS uses some kind of singleton that might cause a false memory leak? Thanks for a great and easy-to-use scripting language.

Detected memory leaks!
Dumping objects ->
{760} normal block at 0x009E9D68, 4 bytes long.
 Data: <    > F8 8A 9E 00 
{759} normal block at 0x009E8F28, 24 bytes long.
 Data: <h               > 68 9D 9E 00 00 00 00 00 01 00 00 00 00 00 00 00 
Object dump complete.


Advertisement
why don't you trace the leak to where it came from?
It seems there is some object that is not released properly when building, I.E. engine->Build(module).

Call stack:
>	Game.exe!asCArray<unsigned long *>::Allocate(unsigned int numElements=3435973836, bool keepData=true)  Line 156 + 0x19 bytes 	Game.exe!asPushActiveContext(asIScriptContext * ctx=0x009e8af8)  Line 118 + 0xa bytes 	Game.exe!asCContext::Execute()  Line 805 + 0x9 bytes 	Game.exe!asCModule::CallInit()  Line 157 + 0xf bytes 	Game.exe!asCModule::Build()  Line 128

I use crtdbg.h to detect memory leaks in all my tests, and I'm not aware of any leaks at all.

Can you show me a small sample that reproduces the memory leak so that I can debug it and fix the leak?

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

Quote:Original post by WitchLord
I use crtdbg.h to detect memory leaks in all my tests, and I'm not aware of any leaks at all.

Can you show me a small sample that reproduces the memory leak so that I can debug it and fix the leak?


This code is kinda baked into my engine. But I think you can make out how it goes.

void print(int value){	char	s[32];	_itoa_s(value, s, 10);		Core::getInstance().getLogger().writeDebug(s);}as = asCreateScriptEngine(ANGELSCRIPT_VERSION);std::ifstream	file(filename);std::string fileString = std::string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());file.close();as->AddScriptSection(module, section, fileString.c_str(), fileString.length());as->RegisterGlobalFunction("void print(int)", asFUNCTION(print), asCALL_CDECL);as->Build(module);as->ExecuteString(module, "void doSomething()");as->Release();

I'll give it a try as soon as possible.

Does it matter what the script looks like?

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

Sorry for the late reply, mate. No, I don't think it matters what the script looks like. I'm using the following:

void doSomething(){    int apa = 123;    print(apa);    print(523);}
Can you generate a leak twice as large?
Hi, Did you tried to use _CrtSetBreakAlloc() to break on the code who made allocation responsible for the leak ?

In your case, you could try :

_CrtSetBreakAlloc( 759 );
_CrtSetBreakAlloc( 760 );

Regards,
Lbas
Lbas
Quote:Original post by NotAYakk
Can you generate a leak twice as large?


Doesn't seem like it. I still get two leaks, even if I create two asIScriptEngine and then release them.

Quote:Original post by Lbas
Hi, Did you tried to use _CrtSetBreakAlloc() to break on the code who made allocation responsible for the leak ?

In your case, you could try :

_CrtSetBreakAlloc( 759 );
_CrtSetBreakAlloc( 760 );

Regards,
Lbas


Yup, check for the callstack in a previous reply here.

This topic is closed to new replies.

Advertisement