Jump to content
  • Advertisement
Sign in to follow this  
Felps

AngelScript memory management

This topic is 917 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

This would be a simple question for the author to answer, and probably anyone who's embeded AS before... I googled, but admit I didn't search this forum specifically for the answer...

 

If I have an object, which stores a static list of pointers to all instances of itself, if I register the type to AngelScript for users to isntantiate, will the pointer always be valid? IE: As long as the object is alive in the script, will the pointer point to the actual script object? Or is there a chance that AS will move the data? 

 

In other words, to properly track the instance, will I have to register a move constructor?

 

 

What I'm doing is making simple little interface objects that abstract away keeping track of indexes, and other complications of my underlying API, and I want it to be as simple as changing an x/y variable on the instance, so I'll need to go through every instance of the interface class and read its data into my sprites, for example, before drawing their positions.  The simpler way to do this would be to make everything a function, but instance.setX(number); is awfully verbose for what should be instance.x = number;

Share this post


Link to post
Share on other sites
Advertisement

I'm not entirely sure what you're asking with regards to memory usage. A lot of it depends on how you register your types to the engine. Angelscript won't move/reallocate instances of reference-counted objects by itself though, if that's what you're asking.

 

You should also note that you can register methods get_x()/set_x() and they will automatically be called as accessors when you use instance.x as a property.

Share this post


Link to post
Share on other sites

This is exactly the information I needed!

 

I was even thinking about making special classes with overloaded assignment operators >.>

I'm not entirely sure what you're asking with regards to memory usage. A lot of it depends on how you register your types to the engine. Angelscript won't move/reallocate instances of reference-counted objects by itself though, if that's what you're asking.

 

You should also note that you can register methods get_x()/set_x() and they will automatically be called as accessors when you use instance.x as a property.

The set_x() method fits my needs perfectly, and eliminates a loop from the first method I thought of...

Edited by Felps

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!