Killing reference counted objects

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Qps
Posts: 18
Joined: Thu Jan 27, 2011 2:02 pm

Re: Killing reference counted objects

Post by Qps »

I used the CTerrainSceneNode as a reference, but i dont see it storing or removing any mesh buffers to a cache. Now please correct me if im wrong, but isnt it so that you can optionally add meshes to the mesh cache and if you do then you should make sure you remove them when dropping the mesh (when you want to completely remove it)?

*Edit:
I think i found the answer to the above question. un less you set the EHM_NEVER the drawmeshbuffer call will decide whether it is usefull to create a hardware buffer.

Also my issue with the meshbuffers randomly not being dropped because the ref count is 1, this is still a bit wierd to me. Since I drop all the mesh buffers using the same code i would expect either all meshbuffers being dropped correctly or all of them not dropping.
Ethon
Posts: 21
Joined: Wed Nov 30, 2011 10:01 am

Re: Killing reference counted objects

Post by Ethon »

All that stuff should be done by using RAII.
Imho its horrible that users are responsible to drop the object, reference counting is better done with smart-pointers like std::shared_ptr/boost::shared_ptr.
That is a guarantee to avoid memory leaks and it has absolutly no overhead compared to calling drop manually.
Post Reply