Memory Management

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am planning to write an explorer like SDI application utilizing ADO
..NET/ACCESS DB.

There will be a number of different detail views (referencing and updating
data on the db) depending on the selected tree node.

I have tried creating multiple pannels and plant controls on them and show
or hide them depending on the tree node. However, It didn't seem like the
right aproach. The size of the executable was gigantic. Once constucted,
the classes couldn't be destructed(framework handles destruction). Problems
re-querying db.

It seems to me that there must me neeter method. All I am looking for is a
general design aproach to this type of application.

Any suggestions would be greatly appreciated.

Thanks in advance
 
Hi



I think that with "size of the executable was gigantic" you mean the
occupied memory at runtime is gigantic. Don't you?

If so I think you may have a memory leak. Yes there are memory leaks with
managed memory.

If so, my advices are:

1.. Read the "Field Views on Windows Forms 1.0 and 1.1 Data Binding" from
msdn.microsoft.com. Mainly the part with "Always Call DataBindings.Clear
when Disposing" must be read.
2.. Call Dispose on the proper Forms/UserControls.
3.. In the Dispose function call ClearBindings The implementation of
ClearBindins can be seen bellow.
4.. Read and use CLR Profiler from Microsoft site. Read carefully there
what means a managed memory leak.


public static void ClearBindings(Control c)

{

Type controlType = c.GetType();

PropertyInfo dataSourcePropertyInfo = controlType.GetProperty("DataSource");

if(dataSourcePropertyInfo != null && dataSourcePropertyInfo.CanWrite)

{

dataSourcePropertyInfo.SetValue(c, null, null);

}



Binding[] bindings = new Binding[c.DataBindings.Count];

c.DataBindings.CopyTo(bindings, 0);

c.DataBindings.Clear();

foreach (Binding binding in bindings)

{

TypeDescriptor.Refresh(binding.DataSource);

}

foreach (Control cc in c.Controls)

{

ClearBindings(cc);

}

}



I hope this helps. I also hope that some-one answer my post as well.

I would also be happy to find out where can I report bugs

for .NET framework 1.1.
 
Back
Top