0

I'm working on a project that have many buttons with pictures, pictures box's and design content in general.

Everything is fine, no memory leaks and optimization is going well.

I've already optimized most images, with icon-res only, most of them are 32x32 or 64x64, they take no memory at all.

The thing is, i'm having a issue with unmanaged memory used by GDIplus, where it takes 90-100 mbs of the memory being used by the program, while the program itself takes 23-25 mbs.

I searched alot, i know that GC don't collect those very often, i need to dispose them. The thing is, i'm loading the images from "proprieties" inside visual studio, not from code. I can't dispose them(at least i dont know how).

After a while (40 min-2 hours) the GC will collect them, and the app still work perfectly, using only 23 mbs of ram.

How can i manage those 90 mbs?

why GC collects after a while and the Memory usage goes to 23 mbs?

I'll leave a snapshot of ANTS.

If anyone finds any memory related problems within this snapshot, please, feel free to comment and point out. I'm very early on computer science, literally 3 months of experience, there's alot to learn.

pardon my english, not my main tongue.

  • Sounds [familiar](https://stackoverflow.com/q/25607397/1997232). TLDR; use [GC.AddMemoryPressure](https://learn.microsoft.com/en-us/dotnet/api/system.gc.addmemorypressure?view=netframework-4.7.2). – Sinatr Jan 23 '19 at 14:13
  • @Sinatr i have read this, i would need to "add" the images to the controls manually? Keep in mind that my program have no leak at all, it was solid for 7 days test straight. – Breno Almeida Jan 23 '19 at 14:23
  • Don't mind my comment, for some reasons I thought you have problems. Are you asking [this question](https://stackoverflow.com/q/1635742/1997232) or why you think extra `90mb` is a problem? – Sinatr Jan 23 '19 at 14:32
  • My program function is monitoring servers across my country. Those 93 mb are related to one screen, that can "watch" 28 servers. I'll add 8 more screens, each one will eat 93 mbs, almost 1gb of unused stuff is pretty bad imo. Here's a screenshot to better "visualization". ![](https://i.imgur.com/bpp6205.png) Btw, i'm using UserControl module, bizarre enough, if i add those panels inside the same user control, they only consume 0.2 mb each(with all buttons and images)... but if i add a new instance of that UserControl, it will consume up to 100 mb of ram. – Breno Almeida Jan 23 '19 at 14:57
  • Does the usage of GDI memory (and handles) grow? – TaW Jan 23 '19 at 18:48
  • @TaW Nope, actually it shrinks (After 40 minutes - 1 and half hour, don't know for sure.) from 120 mb to 23-27 mb, wich suggest that GC is picking them up at some point, and stay that way forever. So, no grow. – Breno Almeida Jan 23 '19 at 18:53
  • Just to clarify what i want: a way to force GC priorize and collect this unmanaged memory. I tried MemoryPressure, with no sucess at all. – Breno Almeida Jan 23 '19 at 19:09

0 Answers0