Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Garbage collection in the .Net MF


  • Please log in to reply
3 replies to this topic

#1 JonnyBoats

JonnyBoats

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts
  • LocationPhillips, ME

Posted 29 March 2011 - 01:38 AM

A key issue for time critical routines (think RTOS) on a Netduino is that application code may be preempted by the .Net MF for Garbage Collection ( see http://msdn.microsof...y/0xy59wtx.aspx for an explanation on how this works on a PC).

Since garbage collection takes time and impacts performance, one does not want it to get out of hand. Basically on the full framework it is so efficient that one hardly ever needs to worry about it for "normal" programs.

As a .Net programmer, I sort of assumed that garbage collection on the MF would be basically the same as on the full framework. Apparently this is not the case!

In watching this video ( http://skillsmatter....-the-path-of-go ) on porting a DLL from the full framework to the X-Box (which uses the compact framework), garbage collection turned out to be a major factor. David Stern spends a good part of the video explaining the differences in how garbage collection works on both the full and compact framework.

Unfortunately he does not address GC in the micro framework, and I have yet to find a good resource that does.

I highly recommend this video to anyone wanting to learn more about how garbage collection works.

#2 demonGeek

demonGeek

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationCanada

Posted 29 March 2011 - 04:55 AM

Interesting video. Given that the Compact Framework only implements one-generation GC, I wouldn't imagine that the Micro Framework is any different. Which leads to an equally interesting observation: In a one-generation GC, every live object on the heap must be considered during each garbage collection. Therefore, the more long-term objects in a NETMF application, the slower the GC cycle. Reducing the number of long-term objects should improve overall GC performance. If correct, that observation will certainly have a bearing on the way I code my NETMF apps. - Adam

#3 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 29 March 2011 - 05:58 AM

Given that the Compact Framework only implements one-generation GC, I wouldn't imagine that the Micro Framework is any different.

The garbage collector in .NET Micro Framework is a simple mark-and-sweep.

#4 demonGeek

demonGeek

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationCanada

Posted 29 March 2011 - 04:43 PM

The garbage collector in .NET Micro Framework is a simple mark-and-sweep.


So do you think that it is a good strategy to avoid long-term objects as much as possible in NETMF code?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.