PDA

Click to See Complete Forum and Search --> : [RESOLVED] Which is more overhead


popskie
Feb 25th, 2007, 09:14 PM
hi,

I have 2 classes can you tell which class is better in memory management?

class class1
{
private dataset mydataset = null;

public void func1()
{
mydataset = new dataset()
//code here
}
public void func2()
{
mydataset = new dataset()
//code here
}

public void func3()
{
mydataset = new dataset()
//code here
}

}

vs


class class2
{
public void func1()
{
dataset mydataset = new dataset()
//code here
}
public void func2()
{
dataset mydataset = new dataset()
//code here
}

public void func3()
{
dataset mydataset = new dataset()
//code here
}

}



Thanks,
Popskie

jmcilhinney
Feb 25th, 2007, 09:24 PM
There's virtually no difference, only a few bytes for the variable. The number of DataSet objects is exactly the same so the actual variables will make no difference. The only possible difference would be with the first one if you didn't set your mydataset variable to null at the end of each call its memory could not be reclaimed until another method was called.

popskie
Feb 25th, 2007, 09:37 PM
Sorry JM for my question. I know how to code the problem is I dont know whats happen during runtime. Again JM thanks, I marked this thread as resolved.