One of the main sources of C / C ++ memory leaks that does not actually exist in .NET is to free shared memory
The following is a class led by the Brad Abrams class for designing .NET class libraries.
"Well, first of all, of course, there are no memory leaks, right? No? Are there any more memory leaks? Well, there is another type of memory leak. How about this? A leak that we don’t have, in the old world you used some memory for malloc and then you forgot to make a free one or add ref and forget to make a release, or whatever the couple is in. And in the new world, the garbage collector ultimately owns all the memory, and the garbage collector frees this stuff when there are no more links. But all there may still be leaks, right? What are the leaks? Well, if you keep the link and this object is alive, then the garbage collector cannot free it. So many times what happens, you think that you got rid of all this graph of objects, but still one guy is holding on to him with a link, and then you are stuck. can free this until you drop all your links to it.
Another, I think, a big question. Lack of memory problems. If you read the WIN32 API documentation, you will see, well, I first distribute this structure and pass it in, and then you populate it, and then I release it. Either I tell you the size, and you distribute it, and then I release it later or you know, all this debate is about who owns this memory and where it is supposed to be freed. And many times, developers simply refuse it and say: “Well, anything. Well, it will be free when the application shuts down,” and this is not such a good plan.
In our world, the garbage collector owns all the managed memory, so the problem of owning the memory, whether it was created and transferred to the application, the application creates and starts to use it. There is no problem with this because they have no ambiguity. The garbage collector owns all this. "
Complete transcription
Conrad Frix Aug 03 2018-10-10T00: 00Z
source share