Jump to content
  • Advertisement
Sign in to follow this  
DarkZoulz

Angelscript 2.7.0 leaks?

This topic is 4360 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
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?

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
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);
}



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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!