Re: Small C# program takes up too much memory



"Chris Mullins [MVP]" <cmullins@xxxxxxxxx> wrote in message news:O%23BD3teVHHA.1636@xxxxxxxxxxxxxxxxxxxxxxx
While I agree with you 100% on every technical level, the user's perception defines reality. Users see the big number in task manager and get cranky. They see a small number, they're happy.

So you mean that:
- all of your users run with administrative privileges, and..
- as such, they know what "Memory Usage" ("Working Set" on Vista) really means or what "Private Bytes" is all about.
Why do they "get cranky" then?
If they don't know exactly what these counters are about, why are they looking at them and why do they "get cranky" then?

I really wish I had a better answer. For almost all the small client-side stuff we do, this works well. Especially as these apps load, and don't really do anything. They're doing almost no processing, no data base stuff - they're just sitting idle and reporting that they're taking 20-50 megs of memory.

Running GC.Collect over & over doesn't even solve the problem - the app still reports a huge amount of memory, and the users perception then is that we suck.


I didn't say that GC.Collect was a solution, I said that both are bad, calling GC.Collect at regular basis disturbs the GC operations, applications that are reducing the WS disturbs the BalanceSet Managers normal operations and is even worse as the BSM is a global resource. In both cases let them do their job, both the GC and certainly the BSM know better than anyone else when they should run.

But again, this is not the real issue, you are forcing your users to run as full admins (a big NO NO per default on Vista) which makes them vulnerable to all sort of security attacks, this is what I call *reality*, tell them about this and let them make an educated choice.

Please - give me a better solution! :)

I don't see a problem (other than running as an administrator), so why asking for a solution :)

Willy.


--
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins

"Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message news:eD7ki6dVHHA.3652@xxxxxxxxxxxxxxxxxxxxxxx
"Chris Mullins [MVP]" <cmullins@xxxxxxxxx> wrote in message news:%23Wk1%237TVHHA.4764@xxxxxxxxxxxxxxxxxxxxxxx
<elty123@xxxxxxxxx> wrote in message:
I have a small C# program (about 400 lines of code) that is only 28kb
after compiled.

However when it runs (takes a whole 5 seconds) it takes up nearly 20MB
of memory and I don't see why.

[...]

Is there anyway I can reduce the memory usage?

This is a pretty common problem. Fortunatly there's a pretty easy solution:

http://www.coversant.net/dotnetnuke/Default.aspx?tabid=88&EntryID=4

--
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins




Chris,
you don't want your applications to run under an administrator account just to fake low memory consumption do you?
Note that doing this is much worse than calling GC.Collect in .NET, all it does is disturb the OSses BalanceSet Manager without any benefit for the user.

Willy.







.



Relevant Pages

  • Re: VIRTUAL MEMORY
    ... In task manager look at the performance tab and repost the PF Usage ... What virus was ... Hard to know if you dont know about computers I know. ... Are you using one of those memory managers which free up memory. ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: GC Handle leaks....
    ... Note that you can use many features of SOS in VS 2005, ... to check the .Net memory and related GC counters and the GC Handles for the ... The handles in Task Manager relates to operating system handles, ... It means the GCHandle doesn't permit the object to be collected. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Physical Memory
    ... Thanks for your help, John. ... As for the services just use the Windows Services Management Console to ... Remote Access Connection Manager ... gig Pentium 4 processor and apparently a half gig of available memory, ...
    (microsoft.public.windowsxp.general)
  • Re: Scalable memory manager for Delphi.
    ... Performance should be equal or better than any other manager on the market. ... We found performance to be generally equal to MultiMM yet offers several ... memory corruption. ... Xeon testing with it, however, the latest demo app hasn't been run on Xeons ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Memory Leak
    ... Regarding .Net memory leak issue, an important step is determing if it is ... should not use the "Mem Usage" column in task manager which is misleading. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.csharp)