Sign in to follow this  
DarkZoulz

Angelscript 2.7.0 leaks?

Recommended Posts

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.


Share this post


Link to post
Share on other sites
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


Share this post


Link to post
Share on other sites
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();



Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by DarkZoulz
It seems there is some object that is not released properly when building, I.E. engine->Build(module).

Call stack:
*** Source Snippet Removed ***


Quote:

Game.exe!asCArray::Allocate(unsigned int numElements=3435973836, bool keepData=true) Line 156 + 0x19 bytes
Game.exe!asPushActiveContext(asIScriptContext * ctx=0x009e8af8) Line 118 + 0xa bytes



numElements = 3435973836 which is 0xCCCCCCCC . This looks like unitialised data.



Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this