none
Memory leak in ADO.Net ? RRS feed

  • Question

  • Background info:

    I have a problem in a large application of ours that I've recreated in the simplest of applications that access a database (Oracle).

     

    The application is contains one windows Forms component. The form contains a tableadapter, a dataset, two textboxes and a button. All components added via the designer. .Net version 2.0

     

    I bind the two textboxes to two different fields in the dataset (no bindingsource in between) via the designer. The click eventhandler for the button contains 1 line of code "tableAdapter1.Fill(dataSet1.datatable1);".

     

    I run the application through a memory profiler that lists all active instances of objects (.Net Memory Profiler).

     

    Problem:

    Each time the fill method is called to fill the datatable the datatable is cleared in the fill method. However one of the rows that is cleared from the datatable is not cleared from memory (.Net profiler show 1 instance of the datarow in addition to the rows that fill retrieves from the database left in memory after each fill).

     

    I've tried Dispose() on the dataset and the datatable. I've tried Clear() on the datatable and dataset. This has no effect. The one thing that solves the problem but isn't really a viable solution in my opinion is to set the dataset to null then reinstantiate it. This however clears any databindings so they have to be "refreshed".

     

    The problem remains the same if I add a bindingsource in between the dataset and the textboxes.

     

    Solution?

    Is there one? What are we doing wrong? I would say this is a serious issue in the ADO.Net framework and from a couple of searches at google more have experienced it, although none has got a proper solution.

    Friday, November 16, 2007 11:02 AM

Answers

All replies