Rule of thumb for System.Drawing

A friend of mine ran into this the other day. If you call a method to get a handle some sort of System.Drawing object, you may be creating an object that needs to be cleaned up through P/Invoke or some other function call. Bitmap.GetHIcon – requires p/invoking DestroyIcon.Font.ToHFont – requires p/invoking DeleteObjectGraphics.GetHdc – requires calling Graphics.ReleaseHdc…

4

Tim resurfaces with another control

I enjoy talking to Tim Dawson quite a bit; we both know that making the decision to build your own menu is not one to be taken lightly.  He’s been busy lately.


How can I figure out how much goo my object is holding onto?

Previously, we figured out a way to eek out class size information from strike.  This is kind of interesting, but you also might want a way to know the size of everything your object instance is holding onto.  There is another strike command called “ObjSize”, which will print out the size of all child objects…


How can I figure out how large my class is?

Phil asks: “Your last post mentions using Marshal.SizeOf to get the byte size of a type that can be marshalled.  I would like to know the amount of space taken up by an object that cannot be marshalled. For example a custom control, so I can then spend time reducing its size and check afterwards…

5

Are you familiar with [ThreadStatic]?

If you’re stuffing anything in thread local storage, you might be interested in the performance comparison between Thread.SetData and [ThreadStatic]. ThreadStatic is super-cool, if you have a static variable, you can make it static “per-thread” by placing the attribute on top.  This is one easy way to get around the thread-safety issues of working with…

12

Steve’s all excited about SQL Everywhere

Steve stopped by earlier in the week to tell me about his latest projects.  He’s really enthusiastic about SQL Everywhere, especially how lightweight it is to install.  There’s even support for adding it to your click-once application setup (that part had me impressed). To prove it, he’s made a video.  And another video.  And another.  I…