Jump to content

does getVerticesData() create a new array ?


jerome
 Share

Recommended Posts

Hi,

 

I will need to tweak the SPS code and to deeply look for any un-needed memory allocations.

 

To update the SPS mesh, I use the getVerticesData(PositionKind) method. I hacked the BJS code to understand whether this function returned a new array each call. I understood it didn't.

Maybe I am wrong.

 

So I would like to be sure it doesn't, please. 

Link to comment
Share on other sites

Looks like it ultimately calls vertexBuffer.getData:

public getData(): number[] {   return this._data;}

Incidentally, I recently found out that chrome has a devtools setting to make the heap profiler record all allocations, so you can get an idea of where memory's being allocated even if it's collected immediately, which would make it really obvious if big arrays are being created and destroyed every frame.

 

Random side note: using this feature, I noticed that even for very simple scenes, StandardMaterial.isReady() churns through a lot of memory. It looks like it's making great big arrays full of strings every frame, so I guess that's why. Anyway in the thing I'm working on, standard Babylon code churns through a lot more temp variables than the user code.

Link to comment
Share on other sites

Random side note: using this feature, I noticed that even for very simple scenes, StandardMaterial.isReady() churns through a lot of memory. It looks like it's making great big arrays full of strings every frame, so I guess that's why. Anyway in the thing I'm working on, standard Babylon code churns through a lot more temp variables than the user code.

 

I'm seeing a few places in that function where they are instantiating arrays.  I wonder why they didn't make those member variables and reset the length to 0 whenever isReady is called.

 

Edit:  Maybe they weren't expecting this function to get hit every frame.  There is a _wasPreviouslyReady property that might not be getting set correctly.

 

Edit 2:  There is a checkReadyOnlyOnce property that you can set.  I wonder when it is appropriate to use that.

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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...