How can I reduce the memory consumption?

L

liubin

I have created a simple program using C#/.NET. It is very small program
without explicit system resources request in the code. However, the memory
consumption is even above 17M(shown in Windows Task Manager), much higher
than 5M of the same one developed with MFC before.

Now I wonder if there is any effective way to optimize .Net program
achieving following two objectives:

1. Reduce system resources consumption of the program created with .NET/C# ?
2. Speed up the program's startup?

Many thanks for your great help!
 
E

Egghead

You can use those,

(1) add this after you finish the start up
GC.Collect()
GC.WaitForPendingFinalizers()
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1)

(2) use "Ngen"


Do not complain the C#.Net app start up time, wait unit you c the VC++.Net
app
BTW, why do not try VC++.net ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top