Hi,

I receive Out of handles when I execute a specific managed application for a
long time (like 2 days). I didn't find any functions to be able to get the
number of handles created by a given process (CE 6.0 R2). How can I debug
this? Appverif doesn't seams to give me good result with a managed
application that uses sockets. And since we do not have the mscoree2_0.map
file anyway it doesn't help a lot.

Any suggestions?

Thanks,

Re: Out of Handles by Paul

Paul
Tue Jun 17 09:09:07 PDT 2008

I don't know of any way to debug it. It sounds like your code is leaking
handles and eventually you run out. Finding leaks is relatively difficult.
Make sure that any objects that you create which are derived from
IDisposable are having their Dispose() methods called. This is commonly a
problem for things like bitmaps, etc. that are Win32 API constructs. Not
calling Close() on file objects can do something similar. Same for registry
keys, etc., etc. Just because the run-time is garbage collected does not
mean that you can ignore memory allocation!

I think you'll have a better chance of finding the problem by inspecting
your code than by trying to find a suitable MAP file or anything like that.

Paul T.

"Vinz" <Vinz@discussions.microsoft.com> wrote in message
news:DF94BF58-424F-4016-AD76-FB56B5F3BEEB@microsoft.com...
> Hi,
>
> I receive Out of handles when I execute a specific managed application for
> a
> long time (like 2 days). I didn't find any functions to be able to get the
> number of handles created by a given process (CE 6.0 R2). How can I debug
> this? Appverif doesn't seams to give me good result with a managed
> application that uses sockets. And since we do not have the mscoree2_0.map
> file anyway it doesn't help a lot.
>
> Any suggestions?
>
> Thanks,



Re: Out of Handles by Vinz

Vinz
Tue Jun 17 09:30:34 PDT 2008

Thanks Paul.

As you said this is hard to debug.

Is there a way to detect that a Dispose on an instance of a class have not
been called. Or maybe an option that can be set to tell the garbage collector
to flag something or break when a Dispose have not been called when an object
is collected?

On a custom class it's easy but for .NET Framework class it may be harder.


Re: Out of Handles by Paul

Paul
Tue Jun 17 09:47:55 PDT 2008

No. If you're not calling it when you're done with the object, assume it's
not called and call it. You should be calling Dispose *explicitly* whenever
you're done with an instance of an IDisposable subclass.

Paul T.

"Vinz" <Vinz@discussions.microsoft.com> wrote in message
news:8BB3AF3C-3336-4400-BD8F-D7D5F9BCFE0B@microsoft.com...
> Thanks Paul.
>
> As you said this is hard to debug.
>
> Is there a way to detect that a Dispose on an instance of a class have not
> been called. Or maybe an option that can be set to tell the garbage
> collector
> to flag something or break when a Dispose have not been called when an
> object
> is collected?
>
> On a custom class it's easy but for .NET Framework class it may be harder.
>



Re: Out of Handles by Steve

Steve
Wed Jun 18 12:23:55 PDT 2008

> Is there a way to detect that a Dispose on an instance of a class have not
> been called. Or maybe an option that can be set to tell the garbage
> collector
> to flag something or break when a Dispose have not been called when an
> object
> is collected?
Try running FxCop - While it's not 100% perfect in all cases for this sort
of thing it is VERY good about catching when you don't call Dispose()
correctly. (There are some weird programming constructs that could fool it
but I'd say that would be quite rare)


--
Steve Maillet
Program Manager - .NET Micro Framework
http://blogs.msdn.com/smaillet