Impact of Garbage Collector

3

The project here is done in Windows Forms and we do not manage the memory very well because it is a legacy system that has several years running.

We are currently experiencing problems with a lack of memory on the computers where the system is running because memory consumption when the system is running is very high.

I have questions about using GC , since I started putting it in almost everywhere, but I stopped to think and I do not know if it is the best way, even more projects in Windows Forms .

My questions are:

  • At what times is it good to clear the memory?
  • Is the ideal time to open and close the screen?
  • On all buttons on the screen?
  • What problems can be caused by excessive use of GC?
  • How could I resolve these out-of-memory errors?

        
    asked by anonymous 20.09.2016 / 19:36

    1 answer

    4
      

    At what times is it good to clear the memory?

    Never. I've answered this before .

      

    Is the ideal time to open and close the screen?

    Never!

      

    On all buttons on the screen?

    Never!

      

    What problems can be caused by overuse of GC?

    Pauses and loss of performance.

    What harm can it do to free up memory?

    That's the real question that needs to be asked. The problem is more in making the manual release of memory than in leaving without doing. Pauses will be more frequent and longer. If there was a memory problem, there is now a management problem. I will not go into detail because this is already explained in the other question.

    It may be overkill in memory usage due to wrong architecture or failure to release. The release is automatic, but the programmer has to know how to do it. It can not keep references to objects.

    Real problem

    I have seen cases of one window calling another that calls the first one, there it turns into a terrible vicious cycle. But most cases are not so terrible, but objects are kept alive for longer than they need.

    There are cases that leave leaking more time than it should. You have pre-need explicit-release objects, at least using using .

    I see most programmers doing code without thinking about how it works. They just want to see the result. That does not work. It takes planning. Without knowing how everything works is at the mercy of coincidence. It can work or not.

    I do not know what the case is about this application, but it is possible that it has serious problems managing the objects. Maybe you'll have to do a profiling . have tools for this:

    You can not rule out the possibility that the application simply needs more memory. There are cases like this. But before investing in hardware you need to make sure you have solved all of the software.

    Now you have better grants to start thinking about the right problem and who knows how to ask specific questions.

        
    20.09.2016 / 20:03