Jump to content

Assets Loading / Memory Management in C++ and Lua.


Hgawmphdmph
 Share

Recommended Posts

Hi all,

I'm in the process of converting key parts of my partially written framework using Leadwerks from Lua into C++ and I have a question about loaded assets and memory management.

Looking at things like the CreateNew load parameter, the Asset path attribute and the Copy function, I'm guessing that if I load the same asset more than once, the API will just return a pointer to the existing instance already loaded, in order to save memory - is that correct?

If so, my real question is, what happens if I load a Texture from C++ and then load the same one again from my Lua code. Will the API return a Lua table pointing to the original asset?

Alternatively, is there some way of accessing a C++ loaded asset or entity from Lua or Lua table of an asset or entity from C++? Last time I tried this I got an access violation.

Cheers and thanks in advance,
Colin

Link to comment
Share on other sites

37 minutes ago, Hgawmphdmph said:

Looking at things like the CreateNew load parameter, the Asset path attribute and the Copy function, I'm guessing that if I load the same asset more than once, the API will just return a pointer to the existing instance already loaded, in order to save memory - is that correct?

Yes.

It doesn't matter if the load command is called from C++ or Lua. The engine uses the same routine to check for the loaded asset by file path.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...