|
But in a managed environment you don't allocate "memory" you allocate
objects. If you needed 200K of memory for <insert you need here> you
wouldn't alloc it, you'd create a new byte[] object, or perhaps a
MemoryStream. Then these are objects, and the GC will know when they are
no longer referenced and can be cleaned up.
The only spot the GC needs help is when you're transitioning to
non-managed code. If you allocate memory and then need to pass a pointer
to that memory to non-managed code, then you need to tell the GC to pin
the memory and leave it alone. The GC can tell when managed code is
using the memory, it can't tell when non-managed code is using it.
Therefore you must then un-pin the memory when it's no longer needed in
the called code.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.