473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

CLR Memory Utilisation

I have a problem with an C# application. The application is a 24x7 low volume message processing server. The server has a single thread of processing, running in a continuous loop, for each iteration thread sleeping for 5 seconds and than reading textual message files from a Windows Folder and applying them to a database.
From an external view, the server appears to have a memory-leek, continuously consuming RAM in a near linier fashion as it runs. I’ve observed the following
• Monitoring the application with perfmon or the windows task manager, the application continuously consumes additional memory at the rate of about half a gigabyte an hour.
• Viewed internally using GC.GetTotalMemory(true), memory consumption fluctuates between 400 and 800 KB and exhibits no trend of increasing memory utilisation.
• Fireing up another application under the .NET environment causes the near linier increase in memory utilisation to de-stabilise and occasionally drop dramatically. The most extreme observed drop was from 1.5GB to just under 1 megabyte
I have tried the application on Windows NT4, 2000 and XP running it under .NET without service packs and separately with service pack 1 and with service pack 2. In each case I’ve seen the same behaviour

Is this known CLR behaviour? Is there any way of restricting the amount of memory available to the CLR

Any thoughts or info would be greatly received. I have an angry client who want’s to move back to J2EE :

Jul 21 '05 #1
11 2761
Hi Jong,

Interesting, what happens when the thread awakes, are you creating "new"
objects while the method never ends?

Just a thought

Cor
Jul 21 '05 #2
Hi Jong,

Interesting, what happens when the thread awakes, are you creating "new"
objects while the method never ends?

Just a thought

Cor
Jul 21 '05 #3
What memory perf. counter shows the increased memory consumption?
If it's not a CLR memory counter, and I assume it's not, you probaly have a
non CLR memory leak.
Did you ever try to attach a debugger to the process?
What version of the framework do you run this on?
What OS and DB versions?

Willy.

"jo**@opentext.com" <an*******@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
I have a problem with an C# application. The application is a 24x7 low
volume message processing server. The server has a single thread of
processing, running in a continuous loop, for each iteration thread
sleeping for 5 seconds and than reading textual message files from a
Windows Folder and applying them to a database.
From an external view, the server appears to have a memory-leek,
continuously consuming RAM in a near linier fashion as it runs. I’ve
observed the following:
• Monitoring the application with perfmon or the windows task manager, the
application continuously consumes additional memory at the rate of about
half a gigabyte an hour.
• Viewed internally using GC.GetTotalMemory(true), memory consumption
fluctuates between 400 and 800 KB and exhibits no trend of increasing
memory utilisation.
• Fireing up another application under the .NET environment causes the
near linier increase in memory utilisation to de-stabilise and
occasionally drop dramatically. The most extreme observed drop was from
1.5GB to just under 1 megabyte.
I have tried the application on Windows NT4, 2000 and XP running it under
.NET without service packs and separately with service pack 1 and with
service pack 2. In each case I’ve seen the same behaviour.

Is this known CLR behaviour? Is there any way of restricting the amount
of memory available to the CLR?

Any thoughts or info would be greatly received. I have an angry client
who want’s to move back to J2EE :(

Jul 21 '05 #4
What memory perf. counter shows the increased memory consumption?
If it's not a CLR memory counter, and I assume it's not, you probaly have a
non CLR memory leak.
Did you ever try to attach a debugger to the process?
What version of the framework do you run this on?
What OS and DB versions?

Willy.

"jo**@opentext.com" <an*******@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
I have a problem with an C# application. The application is a 24x7 low
volume message processing server. The server has a single thread of
processing, running in a continuous loop, for each iteration thread
sleeping for 5 seconds and than reading textual message files from a
Windows Folder and applying them to a database.
From an external view, the server appears to have a memory-leek,
continuously consuming RAM in a near linier fashion as it runs. I’ve
observed the following:
• Monitoring the application with perfmon or the windows task manager, the
application continuously consumes additional memory at the rate of about
half a gigabyte an hour.
• Viewed internally using GC.GetTotalMemory(true), memory consumption
fluctuates between 400 and 800 KB and exhibits no trend of increasing
memory utilisation.
• Fireing up another application under the .NET environment causes the
near linier increase in memory utilisation to de-stabilise and
occasionally drop dramatically. The most extreme observed drop was from
1.5GB to just under 1 megabyte.
I have tried the application on Windows NT4, 2000 and XP running it under
.NET without service packs and separately with service pack 1 and with
service pack 2. In each case I’ve seen the same behaviour.

Is this known CLR behaviour? Is there any way of restricting the amount
of memory available to the CLR?

Any thoughts or info would be greatly received. I have an angry client
who want’s to move back to J2EE :(

Jul 21 '05 #5
Yes Cor

I'm creating new objects within methods called by my infinite loop. However, these objects are transitory and are de-referenced immediately after use (before the completion of a sleep / processing cycle).

Thanks for the thought.

Cheers
Jg.

Jul 21 '05 #6
Hi Will

I was using Process/Virtual Bytes focused on my .Net application process. I originally had a view that I had a memory-leak issue however I found that fireing up another application under the .NET environment causes the near linier increase in memory utilisation to de-stabilise and occasionally drop dramatically. This only occurred when running another .Net application which lead me to believe that the memory utilization was not directly due to my application. My assumption/guess currently is that, in some situations, the CLR can be lazy in returning memory to the O/S and when a competing .Net application is fired up that needs this memory it simply passes the free memory over to the competing application
I have tried the application on multiple O/S installs - Windows NT4 SP6, 2000 SP4 and XP. If have also run it under .NET 1.0 and separately with service packs 1 and 2. In each case I’ve seen the same behavior
All very odd

The memory utilization would not be a problem if I could cap the amount of memory available to the CLR (like you can limit the amount of heap space available to a Java VM). Are you or any one else aware of any way of achieving this

Thank

Jg
----- Willy Denoyette [MVP] wrote: ----

What memory perf. counter shows the increased memory consumption
If it's not a CLR memory counter, and I assume it's not, you probaly have a
non CLR memory leak
Did you ever try to attach a debugger to the process
What version of the framework do you run this on
What OS and DB versions

Willy

"jo**@opentext.com" <an*******@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com..
I have a problem with an C# application. The application is a 24x7 low
volume message processing server. The server has a single thread of
processing, running in a continuous loop, for each iteration thread
sleeping for 5 seconds and than reading textual message files from a
Windows Folder and applying them to a database
From an external view, the server appears to have a memory-leek,
continuously consuming RAM in a near linier fashion as it runs. I’ve
observed the following
• Monitoring the application with perfmon or the windows task manager, the
application continuously consumes additional memory at the rate of about
half a gigabyte an hour
• Viewed internally using GC.GetTotalMemory(true), memory consumption
fluctuates between 400 and 800 KB and exhibits no trend of increasing
memory utilisation
• Fireing up another application under the .NET environment causes the
near linier increase in memory utilisation to de-stabilise and
occasionally drop dramatically. The most extreme observed drop was from
1.5GB to just under 1 megabyte
I have tried the application on Windows NT4, 2000 and XP running it under
.NET without service packs and separately with service pack 1 and with
service pack 2. In each case I’ve seen the same behaviour
Is this known CLR behaviour? Is there any way of restricting the amount

of memory available to the CLR
Any thoughts or info would be greatly received. I have an angry client

who want’s to move back to J2EE :

Jul 21 '05 #7
Hi Jong,

I think that setting them to nothing does nothing for your memory.
In this case you have to dispose them in my opinion

What are you doing?

Cor
Jul 21 '05 #8
Hi Cor, thanks for your response

My understanding was that the GC disposes the object automatically at it’s next opportunity once an object is de-referenced. An excerpt from my code is as follows

protected void LoaderLoop(

â€
while (true) // Forever! :

â€
bRet = CheckForNew(sLocation, xSourceConfig, xTargetConfig)
â€
Thread.Sleep(interval)
â€

â€
public bool CheckForNew(String sPath, XmlNode xSourceConfig, XmlNode xTargetConfig

XMLUtilities oUtil
â€
oUtil = new XMLUtilities()
â€
sPrefix = oUtil.GetXMLValue(xSourceConfig,"FILEPREFIX")
â€
LoaderLoop() Iterates forever sleeping and calling CheckForNew(). CheckForNew() declares variables for a number of objects upfront (oUtil for example in the excerpt) and is passed a number of objects by value. At the end of CheckForNew() despose is not manually called for any of the created objects. The method simply returns (or is aborted due to an exception). The assumption is that the objects created in the arguments (that are not passed by reference) and the objects explicitly created and referenced by local variables in the method body are automatically dereference because referring variable have gone out of scope on method exit leaving the dereferenced object to be garbage collected. My understanding is that there is no need in the code to explicitly call the c# depose equivalent to destructors (?)

Jo

Jul 21 '05 #9
Hi Cor, thanks for your response

My understanding was that the GC disposes the object automatically at it’s next opportunity once an object is de-referenced. An excerpt from my code is as follows

protected void LoaderLoop(

â€
while (true) // Forever! :

â€
bRet = CheckForNew(sLocation, xSourceConfig, xTargetConfig)
â€
Thread.Sleep(interval)
â€

â€
public bool CheckForNew(String sPath, XmlNode xSourceConfig, XmlNode xTargetConfig

XMLUtilities oUtil
â€
oUtil = new XMLUtilities()
â€
sPrefix = oUtil.GetXMLValue(xSourceConfig,"FILEPREFIX")
â€
LoaderLoop() Iterates forever sleeping and calling CheckForNew(). CheckForNew() declares variables for a number of objects upfront (oUtil for example in the excerpt) and is passed a number of objects by value. At the end of CheckForNew() despose is not manually called for any of the created objects. The method simply returns (or is aborted due to an exception). The assumption is that the objects created in the arguments (that are not passed by reference) and the objects explicitly created and referenced by local variables in the method body are automatically dereference because referring variable have gone out of scope on method exit leaving the dereferenced object to be garbage collected. My understanding is that there is no need in the code to explicitly call the c# depose equivalent to destructors (?)

Jo

Jul 21 '05 #10
Hi Jong,

This is not the part where I say I am sure.

In my opinion does setting the reference to null nothing

When you construct your object in a routine (cannot get the name) and that
routine goes out of scope it should (when it has no any references any more
to another object) be destructed by the garbage collector.

However when it stay in scoop or there stays somehow a reference to another
not to dispose object it will not be disposed and you have to do it by hand.

This is just how I understand it until now.

Cor
Jul 21 '05 #11
Hi Jong,

This is not the part where I say I am sure.

In my opinion does setting the reference to null nothing

When you construct your object in a routine (cannot get the name) and that
routine goes out of scope it should (when it has no any references any more
to another object) be destructed by the garbage collector.

However when it stay in scoop or there stays somehow a reference to another
not to dispose object it will not be disposed and you have to do it by hand.

This is just how I understand it until now.

Cor
Jul 21 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: iceColdFire | last post by:
Hi, I am writing some hybrid application s using C/C++ modules together....Here I have created and used a lot of malloc(...) and new(...) operators. I am interested in checking on the...
0
by: Bruce Pullen | last post by:
DB27.2 on AIX 5.2. KEEPDARI = YES MAXDARI = 50 I'm investigating memory paging caused, I believe, by a specific memory-hungry stored procedure and have some questions! 1) Is there a memory...
10
by: jong | last post by:
I have a problem with an C# application. The application is a 24x7 low volume message processing server. The server has a single thread of processing, running in a continuous loop, for each...
0
by: jong | last post by:
I have a problem with an C# application. The application is a 24x7 low volume message processing server. The server has a single thread of processing, running in a continuous loop, for each...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.