C# windows application taking too much of physical memory(private working set)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ratneshwar
    New Member
    • Dec 2014
    • 1

    C# windows application taking too much of physical memory(private working set)

    I have developed a C# windows application in Visual Studio 12. When I run this application, it slows down after 1-2 hours and makes PC slow and afterwards no able to do anything., I think it takes too much of physical memory(when checked win task manager it was about 97%).

    Below is the introduction to application developed :
    The application is very data intensive. The application contains one for loop which loops through around 300000times and this "for loop" also have one "inner for loop" which loops through 50000 time. I store all the data in lists, arrays and objects(I think these data structures consuming memory)
    E.X.
    Code:
    for(i=0;i<300000;i++)
    {
      for(j=0; j<50000;j++)
      { 
        //do some calculations
        // save results into objects and list 
      }
      //create datatable based on object & list and add to dataset
     
    }
    Also suggest how to make this application fast!!!
    Last edited by Frinavale; Dec 3 '14, 02:18 PM. Reason: Added code tags and formatted code so that it is more legible.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Yes, it is the list, arrays, and objects that are using up memory.

    We can not make any suggestions about how to make the code faster or make it use less memory when there's barely any code for us to make suggestions about.

    Comment

    • iam_clint
      Recognized Expert Top Contributor
      • Jul 2006
      • 1207

      #3
      Like rabbit said with such a small amount of information it's hard to tell you how to make it better and or faster. As to memory usage make sure you are disposing of your objects when you no longer need them. More code required to give a better response.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        It is pretty hard to help you with only 2 loop structures to go on.

        The only thing that pops into my mind is: have you considered using parallel programming?

        Implementing parallel loops has own design complications since you need to consider how shared resources are accessed. You don't want your resources to be accessed at the same time and also you need to make sure that you don't end up in a deadlock type situation....

        Aside from the design considerations, but I have found that parallel programming has help to increase efficiency in some components that I have worked on that require processing of large amounts of data.

        Documentation on Parallel Programming:

        -Frinny
        Last edited by Frinavale; Dec 4 '14, 02:59 PM.

        Comment

        Working...