jerome Posted June 27, 2015 Share Posted June 27, 2015 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. Quote Link to comment Share on other sites More sharing options...
adam Posted June 27, 2015 Share Posted June 27, 2015 I'm new to this codebase, but it appears you are fine unless you are setting the the copyWhenShared param to true. Quote Link to comment Share on other sites More sharing options...
fenomas Posted June 28, 2015 Share Posted June 28, 2015 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. jerome 1 Quote Link to comment Share on other sites More sharing options...
adam Posted June 28, 2015 Share Posted June 28, 2015 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. Quote Link to comment Share on other sites More sharing options...
jerome Posted June 28, 2015 Author Share Posted June 28, 2015 Yep, many functions (like computeNormals) weren't initially intended to be called in the render loop but only to build/set things. Arf, this is my fault : I want to distort everything each frame Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.