We help IT Professionals succeed at work.
Get Started

Issu on deserialize an object, memory leak?

CodingCat asked
Last Modified: 2013-11-08
hi experts,

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>();
..........// Deserialize...
    Return myObject;

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?
Watch Question
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE