memory error only when app minimized

S

Smokey Grindel

I have an error I absolutely can not track down the cause of... users will
use our program for hours at a time with no problem, minimize it and go to
work on something else such as using outlook or IE then boom out of no
where..... and very randomly.....

System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.

and this ONLY ever happens when the app is minimized....

is this somehow a side effect of the app freeing up memory when minimized? I
thought I read once windows will "clean up" (page out) app memory when an
app is minimized and idle... could this be causing this? I've never
reproduced it but everyone else here using the app seems to be able to...
unfortunately for me.....

here is the full exception

Exception Information:
System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef
hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at CompanyName.AppName.MainApplication.Start() in
D:\Development\appnamehere\Trunk\app\MainApplication.vb:line 321

and the line it references is just the Application.Run(appContext) command
which ran perfectly until minimized for some time...

any help or direction on where to look would REALLY help out a lot! thanks!
 
G

Gregory A. Beamer

I have an error I absolutely can not track down the cause of... users
will use our program for hours at a time with no problem, minimize it
and go to work on something else such as using outlook or IE then boom
out of no where..... and very randomly.....

System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.

and this ONLY ever happens when the app is minimized....

is this somehow a side effect of the app freeing up memory when
minimized? I thought I read once windows will "clean up" (page out)
app memory when an app is minimized and idle... could this be causing
this? I've never reproduced it but everyone else here using the app
seems to be able to... unfortunately for me.....

I would say that is a distinct possibility it is clearing on minimize
and the app is erroring trying to access freed memory. Perhaps you can
catch the exception and then reconstitute the data your user is working
with (or ignore if minimized)? Perhaps someone else has a better
suggestion (mine is reactive, perhaps something proactive)?

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

My vacation and childhood cancer awareness site:
http://www.crazycancertour.com

*******************************************
| Think outside the box! |
*******************************************
 
S

Smokey Grindel

I've put exception handlers all over the place, it seems like it's an
exception that I just can not catch where it happens... it happens at the
app domain level and crashes 100% of the time at the application.run and
never where the actual crash happened...... its been a real pain in the butt
to track down the only thing I have figured out after a year of watching it
is the fact it only happens when minimized....
 
N

not_a_commie

The AppDomain class has some error events that you could subscribe to
for info on that level.
 
P

Peter Duniho

I have an error I absolutely can not track down the cause of... users
will use our program for hours at a time with no problem, minimize it
and go to work on something else such as using outlook or IE then boom
out of no where..... and very randomly.....

System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.

and this ONLY ever happens when the app is minimized....

is this somehow a side effect of the app freeing up memory when
minimized? I thought I read once windows will "clean up" (page out) app
memory when an app is minimized and idle... could this be causing this?

Could be. But if so, it's still a bug, probably in your code somewhere.

Something like this, you'd really have to post a concise-but-complete code
example. There are just too many things that might be wrong. But,
judging from the stack trace and the particular error, it seems like you
might be using some unmanaged code in your application. If so, I think
the first thing to look for would be to see if you are passing some
managed object to the unmanaged code without properly ensuring it doesn't
get garbage-collected. Also, double-check all the unmanaged code to make
sure it's not corrupting your data (as the exception suggests might be
happening).

Pete
 
S

Smokey Grindel

if I could reproduce it to get the code I would....... because I have no
complete code to post that can reproduce this unfortunately..... yes there
is a com wrapper that is 3rd party that I'm starting to suspect is the
problem
 
G

Gregory A. Beamer

if I could reproduce it to get the code I would....... because I have
no complete code to post that can reproduce this unfortunately.....
yes there is a com wrapper that is 3rd party that I'm starting to
suspect is the problem

Does this third party COM wrapper component contact the database? If so, it
is a very good candidate for the error prone piece.

Peace and Grace,


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

My vacation and childhood cancer awareness site:
http://www.crazycancertour.com

*******************************************
| Think outside the box! |
*******************************************
 
S

Smokey Grindel

nope, no DB contact for it

Gregory A. Beamer said:
Does this third party COM wrapper component contact the database? If so,
it
is a very good candidate for the error prone piece.

Peace and Grace,


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

My vacation and childhood cancer awareness site:
http://www.crazycancertour.com

*******************************************
| Think outside the box! |
*******************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top