Application Unexpectedly Terminates

B

Bill Draper

We are experiencing a problem with our C#-based application occasionally
terminating unexpectedly. So far we have only reproduced it after running
the program heavily for long periods of time, and even then we have yet to
find a pattern leading up to the application exiting. It is a relatively
complex application with quite a few p/Invoke calls as well as some unsafe
code using fixed memory and is fairly graphics intensive. We suspected these
areas first (still do) and have looked at these sections of code over and
over for clues but all appears fine upon inspection. Although we usually do
not see any exceptions being thrown, there are reports of seeing a native
exception error prior to exiting at times. But even this message does not
wait for user interaction but rather just flashes by quickly, and again is
not usually seen at all. Exception handlers do not catch any exceptions in
this case.

The platform is Windows CE 4.2 with all QFE's applied, including SP2 of the
CompactFramework. Does anyone have any debugging ideas that may help us
narrow our search? What sort of things can cause a managed application to
simply exit? Any suggestions/ideas will be greatly appreciated.

Bill
 
C

Chris Tacke, eMVP

If the P/Invoked library gets an exception this can happen and if your
unsafe code steps on something I think it may also cause similar behavior.
 
B

Bill D

Mark,

Thanks for the reply. In your case, it sounds like your app was unexpectedly
closing, but you were getting a WM_CLOSE event on the way out? Since you put
this trap in for that event, are you still ever seeing an 'unsolicited'
WM_CLOSE being sent to your application to shut it down? It would be good to
know the root cause of this if it's still happening. From this, we will put
code in to see if we are seeing a WM_CLOSE on the way out. I'll let you know
what we find...

Thanks again,
Bill


Mark Arteaga said:
I had a similar problem but I was getting my form objects disposed for no
reason and then eventually the application would get shutdown. I assumed it
was a memory problem because the app, like yours is very graphics intensive
and runs multiple threads accessing webservices. What I did was trap the
WM_CLOSE notification (using the ApplicationEX from OpenNETCF.org) and
ignored that message so the application wouldn't close. When this message
was received we tried to release as many resouces as possible(mainly UI) and
force a garbage collection. Our application will be the only application
running on the device so I don't expect this to be a problem. We also tried
to trap WM_HIBERNATE to try and release resources before we were forced to
shutdown (WM_CLOSE) but for some reason that message didn't come through to
the application.
The other thing to remember is every process runs in a maximum of 32mb.
Check out this link
http://msdn.microsoft.com/library/d...ml/_wcesdk_Windows_CE_Memory_Architecture.asp
for more details on the WinCE Mem Architecture.
So far the solution above seems to work and haven't experienced any
problems. It's been running for 2-3 mths under development stage. I'll
know if it really works once it goes into testing!! If someone sees anything
wrong with the above I would like to hear about it :)
 
C

Chris Tacke, eMVP

"Unsolicited" WM_CLOSE messages can occur. If the device runs low on memory,
the device manager will notify apps that they need to reduce their memory
footprint if possible. If after that it is still low, it will start closing
apps. The current app is usually last to die, but if your app is running in
the "background" then it could easily be killed.
 
G

Guest

I suspected it was a memory problem after reading the documentation. That's why i started tracking WM_CLOSE and WM_Hibernate. My only question is we never recieve a WM_Hibernate which is the message that is sent when we should start freeing up resources. Is that message surpressed by the CLR since that's what should be handling memory and not the CF Application

----- Chris Tacke, eMVP wrote: ----

"Unsolicited" WM_CLOSE messages can occur. If the device runs low on memory
the device manager will notify apps that they need to reduce their memor
footprint if possible. If after that it is still low, it will start closin
apps. The current app is usually last to die, but if your app is running i
the "background" then it could easily be killed

--
Chris Tacke, eMV
Co-Founder and Advisory Board Membe
www.OpenNETCF.or
--
--
Principal Partne
OpenNETCF Consultin
www.OpenNETCF.co



Bill D said:
Mark
Thanks for the reply. In your case, it sounds like your app wa
unexpectedl
closing, but you were getting a WM_CLOSE event on the way out? Since yo pu
this trap in for that event, are you still ever seeing an 'unsolicited
WM_CLOSE being sent to your application to shut it down? It would be goo t
know the root cause of this if it's still happening. From this, we wil pu
code in to see if we are seeing a WM_CLOSE on the way out. I'll let yo kno
what we find..
Thanks again Bil
"Mark Arteaga" <ng_[at]_markarteaga_[dot]_com> wrote in messag
I had a similar problem but I was getting my form objects disposed fo
n
reason and then eventually the application would get shutdown. I assume i
was a memory problem because the app, like yours is very graphic intensiv
and runs multiple threads accessing webservices. What I did was trap th
WM_CLOSE notification (using the ApplicationEX from OpenNETCF.org) an
ignored that message so the application wouldn't close. When thi messag
was received we tried to release as many resouces as possible(mainly UI an
force a garbage collection. Our application will be the only applicatio
running on the device so I don't expect this to be a problem. We als trie
to trap WM_HIBERNATE to try and release resources before we were forced t
shutdown (WM_CLOSE) but for some reason that message didn't come throug t
the applicationCheck out this lin
http://msdn.microsoft.com/library/d...tml/_wcesdk_Windows_CE_Memory_Architecture.as
for more details on the WinCE Mem Architectureproblems. It's been running for 2-3 mths under development stage. I'l
know if it really works once it goes into testing!! If someone see anythin
wrong with the above I would like to hear about it :
 
R

Rich Hanbidge [MSFT]

Do you have access to eVC?

eVC provides a JIT (Just In Time) Debugger which you can install. If your
application is getting killed by the OS because of an unhandled exception,
the JIT will catch it and prompt you to attach eVC to the process.

Remember that you need to soft reset your device after you install the JIT.
The OS requires this.

Good luck!

Rich Hanbidge
Visual Studio for Devices
Microsoft Corp.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Thread-Topic: Application Unexpectedly Terminates
| thread-index: AcRCfKkTfUhkN8ihQd+BG59SP6NHsA==
| X-WN-Post: microsoft.public.dotnet.framework.compactframework
| From: =?Utf-8?B?TWFyayBBcnRlYWdh?= <ng_[at]_markarteaga_[dot]_com>
| References: <[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
| Subject: Re: Application Unexpectedly Terminates
| Date: Tue, 25 May 2004 10:21:05 -0700
| Lines: 5
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Path: cpmsftngxa10.phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:53920
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Clicked the "Send" button too soon...here is the rest of my message....

We still recieve the WM_Close we just don't dispatch the message to the
application which stops the application from shutting down. So far this
hasn't caused a problem and everything works fine. It's not the best
solution but for now it's working for now. From my testing I have a
feeling the root cause is the application is running out of memory because
of all the graphics we use and is around 20+ forms. Currently our app is
almost 7MB and more than half is graphics. Let me know what you find. It
would be nice to know if I'm on the right track or not.

Mark.
|
From: =?Utf-8?B?TWFyayBBcnRlYWdh?= <ng_[at]_markarteaga_[dot]_com>
Subject: Re: Application Unexpectedly Terminates
Date: Tue, 25 May 2004 10:26:06 -0700
Newsgroups: microsoft.public.dotnet.framework.compactframework

I suspected it was a memory problem after reading the documentation. That's
why i started tracking WM_CLOSE and WM_Hibernate. My only question is we
never recieve a WM_Hibernate which is the message that is sent when we
should start freeing up resources. Is that message surpressed by the CLR
since that's what should be handling memory and not the CF Application?

----- Chris Tacke, eMVP wrote: -----

"Unsolicited" WM_CLOSE messages can occur. If the device runs low on
memory,
the device manager will notify apps that they need to reduce their
memory
footprint if possible. If after that it is still low, it will start
closing
apps. The current app is usually last to die, but if your app is
running in
the "background" then it could easily be killed.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
---
Principal Partner
OpenNETCF Consulting
www.OpenNETCF.com



Bill D said:
Mark,
Thanks for the reply. In your case, it sounds like your app was
unexpectedly
closing, but you were getting a WM_CLOSE event on the way out? Since you
put
this trap in for that event, are you still ever seeing an 'unsolicited'
WM_CLOSE being sent to your application to shut it down? It would be good
to
know the root cause of this if it's still happening. From this, we will
put
code in to see if we are seeing a WM_CLOSE on the way out. I'll let you
know
what we find...
Thanks again, Bill
"Mark Arteaga" <ng_[at]_markarteaga_[dot]_com> wrote in message
I had a similar problem but I was getting my form objects disposed
for
no
reason and then eventually the application would get shutdown. I assumed
it
was a memory problem because the app, like yours is very graphics intensive
and runs multiple threads accessing webservices. What I did was trap the
WM_CLOSE notification (using the ApplicationEX from OpenNETCF.org) and
ignored that message so the application wouldn't close. When this message
was received we tried to release as many resouces as possible(mainly UI)
and
force a garbage collection. Our application will be the only application
running on the device so I don't expect this to be a problem. We also
tried
to trap WM_HIBERNATE to try and release resources before we were forced to
shutdown (WM_CLOSE) but for some reason that message didn't come through
to
the application. 32mb.
Check out this link

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcemain4/ht
ml/_wcesdk_Windows_CE_Memory_Architecture.asp
for more details on the WinCE Mem Architecture. any
problems. It's been running for 2-3 mths under development stage. I'll
know if it really works once it goes into testing!! If someone sees anything
wrong with the above I would like to hear about it :)
 

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