Boost Application Memory by 10-15%
Started by Valkyrie-MT, Nov 27 2011 08:09 PM
5 replies to this topic
#1
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
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
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
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:
Now in my code, I just call:
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
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
- rockinthesixstring likes this
#5
Posted 29 November 2011 - 05:21 PM
Nice, Valkyrie-MT!
#6
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
http://diybrewery.com
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users