Eric Lippert - What do you think of managed code?
- Posted: Apr 05, 2004 at 9:27 AM
- 13,743 Views
- 7 Comments
Download
How do I download the videos?
- To download, right click the file type you would like and pick “Save target as…” or “Save link as…”
Why should I download videos from Channel9?
- It's an easy way to save the videos you like locally.
- You can save the videos in order to watch them offline.
- If all you want is to hear the audio, you can download the MP3!
Which version should I choose?
- If you want to view the video on your PC, Xbox or Media Center, download the High Quality WMV file (this is the highest quality version we have available).
- If you'd like a lower bitrate version, to reduce the download time or cost, then choose the Medium Quality WMV file.
- If you have a Zune, WP7, iPhone, iPad, or iPod device, choose the low or medium MP4 file.
- If you just want to hear the audio of the video, choose the MP3 file.
Right click “Save as…”
- Mid Quality WMV (Lo-band, Mobile)
- WMV (WMV Video)
Comments Closed
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
What is your strategy for dealing with lapsed listeners?
Are your event publishers always shorter lived than the listeners, so you don't have to deal with them? Do you not use events (or delegates)? Do you unsubscribe in dispose?
Or when you say that you haven't debugged a memory leak in C# do you simply mean what you say? Not implying that you don't have memory leaks, just simply stating that you haven't debugged them..?
John.
In C#, you don't do manual allocation of memory. You don't keep manual track of object references. I.e., you don't even have to allocate an object to handle a reference, or call AddRef or Release. It's very much like VB in that regard, for better or for worse.
If the .NET subsystem takes care of all that stuff for you, you aren't given the opportunity to screw it up.
Of course, if .NET were to screw it up, we'd be in a world of hurt.
The downside is that some .NET APIs are just slow. Take the Bitmap methods "GetPixel" and "SetPixel". Each call locks and unlocks some memory, which is an expensive operation. If you're changing or setting the pixels of a image one by one (in my case, grayscaling the image), you're hurting. So you have to use "unsafe" code, which gives you access to real memory pointers. Here, you have enough rope to shoot yourself in the foot, but at least you can do it quickly. You can operate on a whole region of memory by locking and unlocking once.
Off topic, but I couldn't let it pass. In this particular case, that's not what's happening, IIUC.
GetPixel/SetPixel are GDI+ operations on the Bitmap object. They are handled by the unmanaged GDI+ code, which will (usually?) pass the operation off to your graphics driver. Your graphics driver is, of course, running in kernel mode, so user->kernel->user context switches are required for each call!
This is the same when using GDI+ from unmanaged C++, and was also the case using old GDI as well. Get/SetPixel is horrifically slow.
Oh, and the lapsed listeners problem is an interesting one. Conceptually similar (to me) to circular references in COM.
But the fact remains that there aren't fast managed code operations for manipulating bunches of pixels. You have to get to pointers, which is "unsafe". And, of course, once you get your pointers back, you have the chance to overrun all sorts of memory (speaking from expirience again).
So, the performance hit isn't because the code is managed, but rather because there isn't managed code that does the job well.
(Either that, or I'm completely lost regarding the meaning of managed code. In which case, please someone put me out of my misery.)
I have to agree that .net API's are a little slow. I am using them on my site cool science fair experiments and they seem to drag some with high bandwith usage.
Remove this comment
Remove this thread
close