1

sometime, i can create a 10000x10000 bitmap, sometime i can't

depending on how much available physical RAM is free

I would like to know if there a way to figure out before the process start if there enough memory or not

1
  • You don't list any particular O/S, but you're probably running on something with virtual memory. Just checking the instantaneous free physical memory doesn't mean much. A substantial amount may be used as cache and available on demand. Additional memory may be made available by outpaging other processes. Commented Jun 5, 2012 at 1:06

1 Answer 1

1

You can use this to get the current process:

Process proc = Process.GetCurrentProcess(); 

And then use this to get the private memory usage:

proc.PrivateMemorySize64; 

You could also do this (using System.Diagnostics.PerformaceCounter):

protected PerformanceCounter ramCounter; ramCounter = new PerformanceCounter("Memory", "Available MBytes"); var freeRAMInMB = ramCounter.NextValue(); 

The above would get the the amount of free RAM in MB...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.