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

Boost Application Memory by 10-15%


  • Please log in to reply
5 replies to this topic

#1 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 27 November 2011 - 08:09 PM

In the past I have from time to time built with "Release" mode, and it does, as expected, reduce the size of the application somewhat. But, to my surprise, I was still seeing the output from Debug.Print in the output pane in Visual Studio meaning that all the Debug statements are still in the deployed application! So, I did an expreiment and commented out all of my Debug.Print statements and did another build in Release mode and the size was reduced by another 12% !!! It's about 50 bytes for each Debug.Print statement. This is certainly not the way Debug.Writeline works in the Desktop .NET Framework, and I would expect commands in the Debug class to be removed from a Release build. I have opened a ticket and if you agree with me, Vote for it! Vote here: http://netmf.codeple...m/workitem/1369 -Valkyrie-MT

#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 27 November 2011 - 08:41 PM

I've just written a workaround there, because it may take a while before it is fixed (if ever). According to the comment in [unrelated] issue 1352, "We will most likely fix this issue in teh next release or service pack, but it is unlikely that we can do it before May 2012 anyway".

#3 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 27 November 2011 - 09:55 PM

I've just written a workaround there, because it may take a while before it is fixed (if ever). According to the comment in [unrelated] issue 1352, "We will most likely fix this issue in teh next release or service pack, but it is unlikely that we can do it before May 2012 anyway".


Ah thanks. I see your comments were very similar to my own. I tried a workaround but it doesn't work. Have you actually gotten the Conditional attribute to work?

Here's what I tried:

using System;
using Microsoft.SPOT;

namespace System.Diagnostics
{
    public class Debug
    {
        [Conditional("DEBUG")]
        public static void WriteLine(string text)
        {
            Microsoft.SPOT.Debug.Print(text);
        }
    }
}

-Valkyrie-MT

#4 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 28 November 2011 - 02:43 AM

I got this to work with all the memory benefits:

In the "Debug" Configuration I added the "TINYCLR_TRACE" Conditional compilation symbol, then used this code:

using System;
using Microsoft.SPOT;

namespace System.Diagnostics
{
    public class Debug
    {
        [Conditional("TINYCLR_TRACE")]
        public static void WriteLine(string text)
        {
            Microsoft.SPOT.Trace.Print(text);
        }
    }
}

Now in my code, I just call:


using System.Diagnostics;
...

Debug.WriteLine("Hello World");

I still don't know why the Debug based one above didn't work... well that's not true, I have an idea why it doesn't work, but it's not worth it to me now that I have this workaround.

Also, I checked "Optimize code" for both Debug and Release configurations because it doesn't take much extra time and further reduces the size!

-Valkyrie-MT

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 29 November 2011 - 05:21 PM

Nice, Valkyrie-MT!

#6 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 29 November 2011 - 10:26 PM

Valkyrie-MT, I applied your change and got another couple of KBytes back on my app. It really helps to be able to squeeze memory from different places when you are trying to shoe horn in a lot of functionality in an app. Thanks!
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com




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.