I would like to implement a way for user to load configurations from an .xml file and store it to an object (say a List<object> called OB). The users may allow to open different .xml files during the process. Each time they open a different xml file, the data store OB must also be updated.
The way I'm doing it now is write a static function which will return a new List<object> from the xml file.
// class OpenSave
public static List<Object> Deserialize(string file)
List<Object> myObject= new List<Object>();
When user load a different file, the following code is called:
OB = OpenSave.Deserialize(filename);
My question is, what about the old object pointed to by OB? It seems to me the static function Deserialize create a new List object each time it is called and make OB point to this new object. Is this going to cause something like memory leak?