Search code examples
c#memorymemory-managementgarbage-collection

Delete the memory of a Double data type variable


I'm trying to use Garbage collector, GC.collect(), to delete the memory of my variables after a certain period of time that my program runs. It worked well and did what I needed for my integer variables, however when I attempted this for my Double variables or Long it ran an error, stating that GC.collect is integer based.

My question is, is there an alternative service method that I can use to clear the memory of my variables that are of type double or Long?

Thanks


Solution

  • I might also mention that the garbage collector only cares about objects, i.e. classes. Value types, i.e. int, double, structs, etc are either part of a object, and thus tracked and collected as part of that object. Or part of the stack, and thus released automatically when the method they are used in returns.