Inline...
1. Is it just my natural "Defensive Coding" nature or does anyone else
find this really really scarey? For example, it seems as though, since
MSFT have already said that they will fix this problem, that we're going
to have to check for and code for specific CF versions. Secondly,
performance is dependant on which constructor gets used?!? Thirdly,
exception handling and GC behavior is dependant on which constructor gets
used. So now we're left to do our own memory management and we have no
idea how our performance will/may take a hit when users change to a new
CF.
If you code defensively, you'll never hit this. If you use the
WaitForPendingFinalizers approach, then if it is fixed in a future version,
the exception won't get thrown and the wait will never occur, so in theory
perf will improve with no code modifications.
2. Chris, do you know if the information you posted is specific for CF 1,
CF 2, or both? (I have seen the same (incorrect) behavior on both)
I only tested with CF 2.0 SP1, so I can't say for certain. If I were to
guess I imagine it's been there all along.
3. When do they plan on fixing it? How do they plan on fixing it? How
will their fix impact an application's performance?
I don't work for Microsoft so I have no idea if or when this behavior may
get changed. I can't imagine it would impact perf in any way except the GC
would collect properly without you having to call Dispose. It might
actually be a little slower because it may add an additional check.
4. What other classes in CF (or Full) exhibit such odd (and incorrect)
behavior? Do the CF Team know of any that might jump up and bite us like
Bitmap did to me?
That's like asking what bugs are out there that are unknown. I don't
specifically know of any other behaviors like this, but then there's no
guarantee. The CF is heavily tested, but only through actual use and
feedback will more difficult to find problems get addressed.
5. Why did they do it like this?
I didn't architect it or have any part in coding it, so I have no idea. I
do know that the CF team is full of very good developers and architects, so
I'm sure there was some fundamental reason behind it. Whether is was "good"
or "bad" I can't say. I just may have done things slightly different if the
world were perfect and I got to run things.
6. When will I run out of video RAM? i.e. I'm assuming that I could
still have lots of 'free memory', yet a "new Bitmap (w, h)" call will fail
when video RAM is exhausted. This will throw an OOM exception (perhaps
ArgumentException on Full Framework) when I have a ton of virtual memory
left because it may be allocating memory in the 'dedicated video ram'.
What is your definition of "video RAM"? Many CE devices don't have a
separate graphics controller with its own RAM. Some that do still don't use
it for bus-architecture reasons. And if such hardware is present, the CF
has no idea that its there, so it's purely up to the driver if/when it
should allocate against it. Typically this is used for the display driver's
framebuffer(s)
You could try to allocate and have it throw if you're out of virtual memory.
This is more than an implementation bug, this is a fundamental design flaw
in the CF (and Full Framework which is fixed in its latest version) and
one which goes against the fundamental nature of VM/GC notion. Again, I
love what the CF Team have given us, but IMHO this is a serious failure of
the design, implementation, and testing of .NET at Microsoft.
Again, I see it as a simple implementation bug. When it OOMs on creation,
the runtime should collect, wait for finalizers and allocate again. Plain
and simple. It would then behave like a GC system is supposed to.
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--