Your app is memory intensive? There is a way to check available resources.

A few years back I came across following piece of code during code review that got me really puzzled.

try
{
object obj = new object();
}
catch
{
}

I couldn’t think of any good reason as to what purpose this code would serve. Couldn’t resist and asked the developer of his intention. It was a long discussion but summary is that application was very memory intensive so developer added this as a check on the state of application if it has any memory left to instantiate anymore objects.

Fast foward last week, I was having a discussion with a developer and he was struggling with coming up with a strategy to include some checks to ensure enough memory is available before requestintg a large chunk of memory. I asked him if he heard about MemoryFailPoint class in System.Runtime namespace and he didn’t know about it. Now I am not going to create a detailed description of how to use this class because if you google MemoryFailPoint, it will provide you enough examples. Just thought of sharing it with my 2 blog followers 🙂 in case they are not aware of it.

Advertisements
This entry was posted in .NET and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s