JeffSventora Posted January 17, 2012 Author Share Posted January 17, 2012 I know that C# has it's own garbage collector, but I need to use my own for technical reasons. In C++ my code looks like this:```void Release(void){ --m_uiRefCount; if(m_uiRefCount == 0) delete this;}```As you can see, if the Reference Count equals zero, it deletes itself. How could I achieve the same functionality in C#? I've been looking all over the place… Link to comment Share on other sites More sharing options...
Robin Posted January 17, 2012 Share Posted January 17, 2012 Go ask on a C# forum. Link to comment Share on other sites More sharing options...
Godlord Posted January 17, 2012 Share Posted January 17, 2012 If you are seriously asking this question, then you don't seem to comprehend the difference between heap allocation and heap allocation backed up by a garbage collecting virtual machine. With the latter you'll never have to release any memory yourself (the only thing you could be able to do is hint the garbage collector to free it already, but most garbage collectors don't support that functionality because of sanity reasons).Yours faithfully, Stephan. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now