Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
419
ideal way of disposing the grid
posted

Hello, I have been using wingrid in many of my user controls, sometimes i assign List<Objects> or datatable as the datasource to the grid. could you recommend the best way to dispose off this object as i am facing some memory leak problems where the ultragridrow/ ultragridcells and the strings associated with the above still stay in memory [this information is based on checking it in some .net profilers].

Its recovered sometimes by the GC after sometime, but i wanted to know the best way forward.

thanks

 

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    If you put a grid on a form at design-time, then Visual Studio will handle disposing it for you. The grid, and any other controls in the form's Controls collection, are disposed when the form is disposed.

    If you create controls at run-time in code, and those controls were not created in the designer, then you have to dispose them yourself. One easy way to do this with any control is to simply add it to the Controls collection on the form when you create it and let the form handle it.

    Or you can modify the Dispose method on the form.

    Regarding disposing of the DataTable or List of objects, then that's really not something the grid can get involved in. The grid can't assume that it should dispose it's DataSource when the grid itself is disposed, since you could be using that DataSource for other things.

    So I'm not sure I understand what you are asking here.

Children
No Data