Software written in winforms for transport, allows you to print the accompanying documents. On the datagridview , the right-click menu is made, depending on the selected flight, a report is generated in a new window in the reportViewer, which is actually the printed form of the document. I began to notice that every time the report was invoked, the software process consumes 2–3mb more RAM. I am new to c # I don’t know what to do, please help. Now did this:

Calling a document

 private void callWaybill() { Waybill f6 = new Waybill(); f6.ShowDialog(this); } 

In the basic form did this

 public void Dispose() { GC.WaitForPendingFinalizers(); GC.Collect(1, GCCollectionMode.Forced); } 

When closing a form with a document, I do this:

 private void Waybill_FormClosing(object sender, FormClosingEventArgs e) { main m = this.Owner as main; m.Dispose(); } 
  • 2
    No, you are doing wrong. Manual garbage collection cannot help in principle. If you have a memory leak, take any memory profiler and see where it leaks. - VladD
  • @VladD, thanks for the answer, would you recommend some kind of memory profiler for nubas? - Winteriscoming
  • Take ANTS , he is in my opinion a good one. It costs money, but a two-week free period, so you’ll have time to solve the problem. (Well, if the problem occurs frequently, make the authorities buy if it suits you.) - VladD
  • @VladD, set, but I still can not understand how he can help, I see in him just an increase in memory usage, which, in principle, I saw in the task manager. I think there may be a problem in that with every click I generate a new form, and when I stop working with it (when the user closes it with a click on the cross) it remains somewhere in the background and a new one is created, can they be destroyed as it is? - Winteriscoming
  • one
    Unmanaged is not a bunch, it is a native memory. You do not use native libraries by chance? Well, and still look at the list of added objects, it is important . - VladD

0