c# - Do i need to free the memory after using a string list with object type -
i want create collection class can collect type of data (string, int, float). decided use list<object>
structure store kind of data.
since using list structure safer (managed) creating unmanaged array, want create list structure can hold kind of data... have concerns if create list<object>
structure , try hold strings, there memory leaks because of string type..
so have somethings after using (emptying) list , deallocate strings individualy or .net handle that...
is there nicer method creating general collection class?
you won´t need garbagecollect objects on own long need to, according post that´s not case here, necessary in few cases (you may here these cases might be). .net frees memory no references exist (indepenedend if have int, string or custom object), if leave scope of array, list or whatever use contained elements eliminated @ none-deterministic point of time gc, won´t take care this.
what mean managed , unmanaged fact, list bit more dynamic can change size depending on current number of elements. if number exceeds given maximum list automatically increaes given factor. array fixed in size however. term "unmanaged" relies c++ e.g., c#-code allways managed code (which means there garbage-collector e.g.). see wikipedia on managed code
Comments
Post a Comment