Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


- - - - -

array with object reference


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 loboWu   Members   -  Reputation: 201

Like
0Likes
Like

Posted 10 February 2014 - 12:13 AM

Dear Andreas:
I found there's something strange about array constructor in 2.18.1.
 
I had a string class which is registered with reference.
The codes are similar with http://www.gamedev.net/topic/639252-asobj-ref-and-asobj-value-at-the-same-time/
 
and here is my testing code without fail
 

import void SetCurrentModel(string) from "model2";

void test(uint idx)

{
<span  style="color:#ff0000">string@[]</span> models={"111", "222", "333", "444", "555", "666", "666"};

if (idx <=6) SetCurrentModel(models[idx]);

else

SetCurrentModel("");

}


 
If I change the string array codes like this

 
import void SetCurrentModel(string) from "model2";

void test(uint idx)

{
<span  style="color:#ff0000">string[]</span> models={"111", "222", "333", "444", "555", "666", "666"};   //replace "string@ " with "string"

if (idx <=6) SetCurrentModel(models[idx]);

else

SetCurrentModel("");

}

There are some string memory leak in 2.18.1. (but that's fine in 2.17.0)

I couldn't point out the bug exactly, but I think there are 2 bugs with object reference array

1.  value assignment operators on reference types

2.  CScriptArray::Construct()



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3416

Like
0Likes
Like

Posted 10 February 2014 - 09:17 AM

Thanks. I'll look into this.


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

#3 Andreas Jonsson   Moderators   -  Reputation: 3416

Like
0Likes
Like

Posted 10 February 2014 - 06:02 PM

I'm not able to reproduce any problem. The following tests work correctly without any memory leaks.

 

// Test initializing an array with string registered as reference type
// http://www.gamedev.net/topic/653233-array-with-object-reference/
{
  engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
  engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL);
  RegisterScriptString(engine); // ref type
  RegisterScriptArray(engine, true);
  engine->RegisterGlobalFunction("void assert(bool)", asFUNCTION(Assert), asCALL_GENERIC);
 
  r = ExecuteString(engine, "string@[] a = {'a', , 'c', , 'e'}; assert( a[1] is null ); assert( a[2] == 'c' );");
  if( r != asEXECUTION_FINISHED )
    TEST_FAILED;
 
  r = ExecuteString(engine, "string[] a = {'a', , 'c', , 'e'}; assert( a[1] == '' ); assert( a[2] == 'c' );");
  if( r != asEXECUTION_FINISHED )
    TEST_FAILED;
 
  engine->Release();
}

 

Make sure you have updated the CScriptArray add-on with the latest version from the SDK.


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

#4 loboWu   Members   -  Reputation: 201

Like
0Likes
Like

Posted 11 February 2014 - 04:14 AM

Dear Andreas:

   I could reproduce the bug.

   But it occurs only when loading bytecode and run.

   

 

   I think there are 2 bug

   1.  string[] ar = {"a", "b", "c", "d", "e", "f", "g"}   has memory leak,

       in my env, the memory leak maybe   "e" , "f", "g" .....

 

   2. when calling SetCurrentModel(ar[2]), it will raise an exception 

      at string opAssign() with an illegal parameter. 

 

   Thanks a lot.



#5 Andreas Jonsson   Moderators   -  Reputation: 3416

Like
0Likes
Like

Posted 11 February 2014 - 09:31 AM

OK. I didn't test with loading pre-compiled bytecode. I'll check that tonight.

 

It sounds like the bug is in the as_restore.cpp then.


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

#6 Andreas Jonsson   Moderators   -  Reputation: 3416

Like
0Likes
Like

Posted 11 February 2014 - 05:41 PM

That was it. 

 

I've fixed the problem in revision 1833.

 

Thanks,

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

#7 loboWu   Members   -  Reputation: 201

Like
0Likes
Like

Posted 11 February 2014 - 07:02 PM

Thanks a lot.biggrin.png






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS