Memory problem

J

Jakub Cermak

Hello,
I've problem with amount of allocated memory.
System.GC.GetTotalMemory(false) returns, that I have allocated about
5MB, but task manager says that my process is consuming more than 60MB -
how is this possible? How to reduce consumed memory?
--
Best regards,

Jakub Cermak
ICQ 159971304
http://cermi.wz.cz
 
N

Nicholas Paldino [.NET/C# MVP]

Jakub,

Task manager is showing you the working set, not the memory allocated.

If you want a number to compare the call of GetTotalMemory against,
check out the performance counters for .NET. They will give you the
information you are looking for.

Hope this helps.
 
J

Jakub Cermak

Nicholas said:
Jakub,

Task manager is showing you the working set, not the memory allocated.

If you want a number to compare the call of GetTotalMemory against,
check out the performance counters for .NET. They will give you the
information you are looking for.

Hope this helps.

No, it didn't. I don't need to determine how much memory I'm using, I
need to lower total allocated memory in taskmanager. Because there is
quite big difference between 60-100MB and 5MB. It is server application,
and I need to use as less memory as possible .... there is no much RAM :(

--
Best regards,

Jakub Cermak
ICQ 159971304
http://cermi.wz.cz
 
C

Chris Dunaway

Jakub said:
No, it didn't. I don't need to determine how much memory I'm using, I
need to lower total allocated memory in taskmanager. Because there is
quite big difference between 60-100MB and 5MB. It is server application,
and I need to use as less memory as possible .... there is no much RAM :(

You're missing the point. TaskManager is *WRONG*. It does not
accurately reflect the amount of memory your app is using. Check out
this article:

http://blogs.msdn.com/tess/archive/2006/09/06/742568.aspx
 
W

Willy Denoyette [MVP]

| Hello,
| I've problem with amount of allocated memory.
| System.GC.GetTotalMemory(false) returns, that I have allocated about
| 5MB, but task manager says that my process is consuming more than 60MB -
| how is this possible? How to reduce consumed memory?
| --
| Best regards,
|
| Jakub Cermak
| ICQ 159971304
| http://cermi.wz.cz

System.GC.GetTotalMemory returns the amount of managed memory, that is the
amount of memory allocated from the GC collected heap. Taskman shows you the
Working Set (Mem Usage) and the Virtual bytes used by the process.
5MB of managed memory and a Working set of 60MB is in general an indication
that you (directly or indirectly) are allocating unmanaged memory, which you
you fail to release. Now the question is what kind of application is this
and what exactly are you loking at in taskman (Mem usage or VM Size)


Willy.
 
J

Jakub Cermak

Willy said:
System.GC.GetTotalMemory returns the amount of managed memory, that is the
amount of memory allocated from the GC collected heap. Taskman shows you the
Working Set (Mem Usage) and the Virtual bytes used by the process.
5MB of managed memory and a Working set of 60MB is in general an indication
that you (directly or indirectly) are allocating unmanaged memory, which you
you fail to release.

I'm not using unmanaged memory directly and I use just MySQL connection
libraries and standard system libraies
(System.Xml,System.ServiceProcess,System.Data,System.RuntimeRemoting).
Can it be reason?


Now the question is what kind of application is this
and what exactly are you loking at in taskman (Mem usage or VM Size)
I mean VM Size + Mem usage together


--
Best regards,

Jakub Cermak
ICQ 159971304
http://cermi.wz.cz
 
G

Guest

Jakub said:
I've problem with amount of allocated memory.
System.GC.GetTotalMemory(false) returns, that I have allocated about
5MB, but task manager says that my process is consuming more than 60MB -
how is this possible? How to reduce consumed memory?

Those numbers are very difficult to compare.

GC.GetTotalMemory returns the memory your application
has allocated from the .NET runtime.

The task manager displays working set. Even if we ignore
the difference between working set and memory, then
this includes:
* the memory .NET has allocated from Windows for heap usage
(which may be different from what your app has allocated from .NET)
* memory used by .NET runtime itself and various unmanaged
ressources

60 MB sounds a little high, but it is actually not much memory
theese days.

Arne
 
W

Willy Denoyette [MVP]

| Willy Denoyette [MVP] wrote:
| > >
| > System.GC.GetTotalMemory returns the amount of managed memory, that is
the
| > amount of memory allocated from the GC collected heap. Taskman shows you
the
| > Working Set (Mem Usage) and the Virtual bytes used by the process.
| > 5MB of managed memory and a Working set of 60MB is in general an
indication
| > that you (directly or indirectly) are allocating unmanaged memory, which
you
| > you fail to release.
|
| I'm not using unmanaged memory directly and I use just MySQL connection
| libraries and standard system libraies
| (System.Xml,System.ServiceProcess,System.Data,System.RuntimeRemoting).
| Can it be reason?
|
I can't tell, you have to measure. Run your application and check the
perfomance counters, or better run your application in a profiler.

|
| Now the question is what kind of application is this
| > and what exactly are you loking at in taskman (Mem usage or VM Size)
| >
| >
| I mean VM Size + Mem usage together
|

You should NOT add these!


Willy.
 

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