Detecting low memory
-
Hi all, I am trying to have my program detect when the system's memory is low. Is there an event or a windows API that I can use to achieve this? Thanks in advance.
-
Hi all, I am trying to have my program detect when the system's memory is low. Is there an event or a windows API that I can use to achieve this? Thanks in advance.
What for? No, I don't think you can do that in a reliable way, short of actually requesting lots of memory until you aren't getting any more. Each new version of Windows is trying harder to have all memory in use all the time, by caching everything they encounter. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Hi all, I am trying to have my program detect when the system's memory is low. Is there an event or a windows API that I can use to achieve this? Thanks in advance.
It's called
try/catch
. That's the best you can do. Besides, what *is* low memory in windows? It pages to disk, so you shouldn't have to worry about it..45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
Hi all, I am trying to have my program detect when the system's memory is low. Is there an event or a windows API that I can use to achieve this? Thanks in advance.
-
What for? No, I don't think you can do that in a reliable way, short of actually requesting lots of memory until you aren't getting any more. Each new version of Windows is trying harder to have all memory in use all the time, by caching everything they encounter. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
I just need to find a way that will let me know if the OS's memory/resources is low. Is there a windows API or maybe an event in .Net that I can just plug-in to?
-
I just need to find a way that will let me know if the OS's memory/resources is low. Is there a windows API or maybe an event in .Net that I can just plug-in to?
I haven't had it happen since I got more than 512MB ram, and set a decent size page file, however I recall windows pops a message for you if you are running out of memory. It would ask permission to increase the size of the page file. Leave it to Windows I say.
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles] [My Website]
-
Hi all, I am trying to have my program detect when the system's memory is low. Is there an event or a windows API that I can use to achieve this? Thanks in advance.
Yes, you can observe the GC.GetTotalMemory, query the WMI information or use the unmanaged APIs. But as you've been told above, this does not make much sense in general... Your question makes sense, if your application itself manages chunks of memory for specific purposes, such as caching. P.S. The situation is different, if we are talking about some kind of mobile device...
modified on Sunday, August 29, 2010 6:54 AM
-
Hi all, I am trying to have my program detect when the system's memory is low. Is there an event or a windows API that I can use to achieve this? Thanks in advance.
It's generally pointless to try.