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

Troubleshooting Memory

Memory

  • Please log in to reply
4 replies to this topic

#1 bgreer5050

bgreer5050

    Member

  • Members
  • PipPip
  • 28 posts

Posted 09 March 2015 - 06:16 PM

How do I view how much memory I have available when debugging the Netduino Plus 2 ?  I added Debug.EnableGCMessages(true) thinking this would show me the memory situation in the output window.  Do I need to use Debug.GC(true) as well ?  If so, what is the recommended practice as far as where to place the Debug.GC.  Do I place it before a potential problem routine starts or should it be the first line of the routine ?



#2 Juzzer

Juzzer

    Advanced Member

  • Members
  • PipPipPip
  • 135 posts
  • LocationHertfordshire, UK

Posted 09 March 2015 - 06:52 PM

true forces the GC to run and release memory.

You want Debug.Print(Debug.GC(false).ToSting());



#3 bgreer5050

bgreer5050

    Member

  • Members
  • PipPip
  • 28 posts

Posted 10 March 2015 - 03:55 PM

For the Netduino Plus 2, at what value should I start worrying that my code is inefficient ?



#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 10 March 2015 - 07:27 PM

Hi bgreer5050,

What kind of metric/test are you looking for, regarding efficiency? Generally speaking, using extra RAM doesn't hurt your project--unless you need it for something else. It's going to be filled with "empty data" and consume power if you don't use the RAM.

BTW, if you're building something which needs to run for very long periods of time and handles lots of data, we generally recommend pre-allocating RAM using class-scoped variables. That way memory is only allocated from the remaining heap--and the GC is only activated--for things which need temporary memory allocation.

Chris

#5 bgreer5050

bgreer5050

    Member

  • Members
  • PipPip
  • 28 posts

Posted 15 March 2015 - 03:10 PM

Thanks Chris.  I will take your advice into account and pre-allocate.







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.