I have this app which monitors the temperature of my cpu. I also placed memory cleaning garbage collector everytime the function finishes cause I noticed an increasing usage of cpu memory.
However, after how many hours like 3 hours, the app crashes stating memory problem.
I doubt that. The only sensible definition for "CPU memory" would be cache but you're almost certainly talking about RAM, which is just general memory and nothing to do with the CPU. An increase in RAM usage isn't necessarily an issue, because that's a measurement of memory that has been allocated, not what is being actively used. It is less onerous for new memory to be allocated when an application needs it rather than reusing memory that was previously allocated and may no longer be needed. The memory no longer being actively used is cleaned up later, e.g. when a form is minimised. That said, it sounds like the memory allocated to your app isn't being reclaimed at all, or at least sufficiently. That may be because your app isn't properly flagging it as unused or it may because your app is always too active for GC to occur.
Originally Posted by genlight
However, after how many hours like 3 hours, the app crashes stating memory problem.
How do I resolve this memory problem properly ?
There's just no way that we can answer that because the reason will be specific to your code. We'd need to know far more detail about what your code is doing and how. In general though, be sure to dispose any objects that support it once you're finished with them and ensure that your code doesn't hold references to objects (particularly large object, e.g. Images) longer than it needs to. If you're actually calling GC.Collect and you're still seeing memory usage go beyond what it should, my first guess would have to be that you're not doing the latter and possibly not the former either.
this is in relation to my previous post about making an icon for my systray icon where the icon comes from a temperature text value.
yes I have objects and I properly dispose() them after using them and at the end of the code, I also gc.collect. I can see that the memory it is using in KB is 1700 to 3000 and goes back to 1700 after gc.collect has been executed. but even so, at some time, the app crash.
The memory I mentioned that was increasing was on the commitsize and paged pool. Like my commitsize is from 32000 and increasing by 1.
The paged pool is from 300 and increasing by 1 perhaps every 20 seconds. I am not sure though what this paged pool and commit size is all about found on taskmanager, processes tab.
This is the only forum I use where attached images are intentionally resized to be completely illegible.
What few numbers I see look trivial. That's not "runaway memory usage". I can't read what the error says but it doesn't even look like it has words that imply memory usage?
Calling the garbage collector manually rarely fixes things. At best, you usually slow your program down. At worst, you slow it down A LOT. If you aren't having a "sawtooth" pattern of memory usage, where it steadily increases then drops as GC passes happen, then odds are you are leaking unmanaged memory. That memory doesn't belong to the GC, so no matter how hard you try you can't get the GC to collect it.
If you're monitoring your CPU temperature, you're likely using something unmanaged to do so even if you don't realize it. We can't talk about your memory usage if we can't see your code. Maybe you're right, and you are cleaning up after yourself. We'll be the judge of that. It could be that the thing you're using has a memory leak: in that case it's not your fault and they have to fix it.
This answer is wrong. You should be using TableAdapter and Dictionaries instead.