Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Memory usage

Memory usage

Scheduled Pinned Locked Moved C#
performancetestingsalestoolstutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Oleksandr Kucherenko
    wrote on last edited by
    #1

    Hi! I have some questions: 1. Does anyone know how in runtime detect how many memory used by each class? 2. Does anyone know how to minimize memory usage of application (like unloading of unneeded assemblies or something else)? 3. Does anyone know any resource with "performance" + "memory usage" tests on Windows.Forms? I have such situation: I wrote application which make some automation tasks like send e-mail, generate Excel reports (office automation) and etc. Application is not too large but it’s usage of memory make customer dizzy. As you know customer dizzy become a developer soon. Now I have a great :( task to minimize memory usage of application. First of all I need to know how many each class use memory, second step rewrite code of such classes. To my opinion 30-40 Mb memory usage (on computer with 128 Mb) for garbage collector is good enough... Good Luck Alex Kucherenko

    P 1 Reply Last reply
    0
    • O Oleksandr Kucherenko

      Hi! I have some questions: 1. Does anyone know how in runtime detect how many memory used by each class? 2. Does anyone know how to minimize memory usage of application (like unloading of unneeded assemblies or something else)? 3. Does anyone know any resource with "performance" + "memory usage" tests on Windows.Forms? I have such situation: I wrote application which make some automation tasks like send e-mail, generate Excel reports (office automation) and etc. Application is not too large but it’s usage of memory make customer dizzy. As you know customer dizzy become a developer soon. Now I have a great :( task to minimize memory usage of application. First of all I need to know how many each class use memory, second step rewrite code of such classes. To my opinion 30-40 Mb memory usage (on computer with 128 Mb) for garbage collector is good enough... Good Luck Alex Kucherenko

      P Offline
      P Offline
      pallep4
      wrote on last edited by
      #2

      I don't have answers for all of your questions, but here something to get you started If you are creating COM objects then you can force their release by doing MyObject=null; System.GC.Collect(); System.GC.WaitForPendingFinalizers(); System.GC.Collect(); Be carefull when looking at memory usage in the Task Manager it isn't telling you the whole truth.:eek: To determine the real memory usage of an application you could: ' Visual Basic .NET Dim NotepadMemory as Integer Dim component1() as Process component1 = Process.GetProcessesByName("Notepad.exe") NotepadMemory = component1(0).PrivateMemorySize Console.WriteLine("Memory used: " & NotepadMemory & ".") // C# int memory; Process[] notepads; notepads = Process.GetProcessesByName("Notepad.exe"); notepadMemory = notepads[0].PrivateMemorySize; Console.WriteLine("Memory used: {0}.", notepadMemory);

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups