How to catch an out of memory exception vb.net -



How to catch an out of memory exception vb.net -

seems relatively easy question, have tried few things , not figure out how grab exception of type out of memory. here couple things have tried:

try grab ex exception if ex = outofmemoryexception ' here end if end seek seek grab ex exception dim check new outofmemoryexception if ex = check ' here end if end seek

i using display message when out of memory exception thrown, ideal (if possible) able grab type of exception when thrown.

p.s - no cannot avoid type of exception because application , needs able run on older machines.

first of all, not how handle exception of given type. instead, catch type:

try … grab ex outofmemoryexception … end seek

secondly, don’t handle outofmemoryexception. can’t, because ran out of memory , in situations there nil can it, except (carefully, without allocating more memory) logging error.

outofmemoryexception (and stackoverflowexception) fatal: when thrown, scheme informs of error doesn’t give chance prepare it.

in rare cases, can seek freeing allocated no longer needed memory. but, in garbage collected world of .net, exceedingly rare situation.

vb.net out-of-memory

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -