Replies: 4 comments 16 replies
-
What should happen if the object is deallocated while still being referenced? References to a deallocated object could end up pointing to a new or moved object of the same type (logic issues), of a different type (memory corruption), or to something random in the middle of an object (memory corruption again). |
Beta Was this translation helpful? Give feedback.
-
Even if the runtime did add support for this there'd be no need to add a specific language feature to support it. It could be exposed as a method: var clsObject = new Class1();
clsObject.Method();
GC.Delete(ref clsObject); Not sure how well such a concept would work, though. At best it could be a hint if the reference happened to be the only reachable root reference. Otherwise there's no safe way to deallocate the reference. |
Beta Was this translation helpful? Give feedback.
-
For complement: If you want to reduce or remove the GC pressure contributed by an object, you need to change the way it's allocated, not only the way it's deleted. Once allocated onto the normal ephemeral heap, its GC pressure is already commited. |
Beta Was this translation helpful? Give feedback.
-
I'm just going to close this out. This is such a radical change to our entire programming model that it will never happen, unless driven by unquestionable need, and massive demonstrable benefits. The OP lacks any information to motivate either. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
C# should has the ability to allocate and deallocate objects, this should be incorporation with GC, without stressing it
For example :
var clsObject = new Class1();
clsObject.Method();
delete clsObject ;
Beta Was this translation helpful? Give feedback.
All reactions