❔ Dictionary and memory hijinks
I'm writing a console currently, I register objects that implement the
IConVar
interface exclusively, they can be registered from any class at any time for any reason that's needed. And if other classes wanna access them, they can (think of the UE4 console basically), the thing I'm scratching my head over right now is whether or not this type of function will return a copy, or just the object itself that was registered inside of another class previously (i.e, I make and instantiate a new object from a class implementing IConVar
, register it to the Dictionary, will searching up the dictionary return that instance I used to register it into the dictionary, or will it return a brand new copy)5 Replies
I come from a C++ background, so I tend to not be entirely sure on how the GC/Memory Management of C# will handle these types of situation (cause over there I can just use a std::vector of pointers)
It will return a reference to the instance stored within the dictionary
Thanks!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.