473,587 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Collection memory usage in debug build

I'm working on a service for a project that is producing some bizarre
behavior. In debug mode while the service is running, the memory usage
of the service (watching with process explorer) goes from 18MB to 34MB
to 711+MB back down to 51MB then down to 18MB every 1-2 minutes. The
service maintains a List<t,v> of 4400 objects that are being processed
throughout the services life. No secondary objects are created nor
released.

I can understand the 18MB of usage but why on earth does the service
"jump" to over 700MB of memory usage then back down to 50 and then to
18. What could the GC being doing with 700+MB of memory than the
service even uses? In release mode the service consumes 18-25MB on
average over a 12 hour run, it's just in debug that things go insane.

What could possibly be going on?

Note : This didn't happen when we built in VS2003. Since going to
VS2005 and building with generics we get this debug memory nuttyness.

Dec 12 '05 #1
5 2209
Can you give us an example of your code implmentation?

Dec 12 '05 #2
Off the back anytime you are using ANY stream object be sure to wrap it
in a "using" statement. This will insure that the stream is closed and
properly disposed of when you it falls out of scope.

http://msdn.microsoft.com/library/de...pspec_8_13.asp

http://www.c-sharpcorner.com/Code/20...gStatement.asp

Hope this helps.

Dec 13 '05 #3
After blocking out code segments and monitoring I've been able to
whiddle down the part that appears to be the culprit and I've included
the two methods below. CRCGenerationT runs as a thread and calls
GenerateCRC32 around 4-5 times/sec. I didn't create the CRC part I'm
just trying to make it work.

After adding a GC.Collect at the end of the GenerateCRC32 I've brought
memory consumption during debug builds down to ~33MB and I have yet to
see any of those 700+ MB spikes, remove the garbage collection and
bingo, 700-900MB memory spikes.

Here's the code snippet - hopefully it's enough to point out what I
need to rewrite. I'm looking for the code for the Inc and Dec
UpdateFileIOCou nter's but all they do from looking at the MSIL is call
[performancecoun ter].Increment(). Thread wise I dont know if thats
causing an issue.

private void CRCGenerationT( ) {
int TSleepDuration = GetMSSleepDurat ion(idleTiming) ;

while(ProcessFi leCRCs) { // thread flag from baseio.cs
if(fileCRCProce ssedIndex != fileCollection. Count) {
GenerateCRC32() ;
++fileCRCProces sedIndex;
Thread.Sleep(TS leepDuration);
}

if(fileCRCProce ssedIndex == fileCollection. Count &&
IsScanningCompl ete)
ProcessFileCRCs = false;
}
this.TCRC32Thre adDequeue = false;
}

private void GenerateCRC32() {
try {
FileStream CRCFileStream = new
FileStream(IFil eCol[fileCRCProcesse dIndex].FullIOName, FileMode.Open);
StreamReader CRCStreamReader = new StreamReader(CR CFileStream);
crcReader = CRCStreamReader .ReadToEnd();
CRC.Init(CRCToo l.CRCCode.CRC32 );
byte[] rawBytes =
System.Text.ASC IIEncoding.ASCI I.GetBytes(crcR eader);
ushort usCrc32 = (ushort)compCRC .crctablefast(r awBytes);

fileCollection[fileCRCProcesse dIndex].Hash =
usCrc32.ToStrin g();
IncUpdateFileIO Counter(Counter s.Methods.GenCR C32);
}
catch {
fileCollection[fileCRCProcesse dIndex].Hash = string.Empty;
DecUpdateFileIO Counter(Counter s.Methods.GenCR C32);
}

GC.Collect();
}

Dec 13 '05 #4
Happens to all of us!

Good luck

Dec 13 '05 #5
I'll wrap a using block around it now and run some tests. Thats just
one of those things that after days of staring at code one just kind of
forgets. Thanks.

Dec 13 '05 #6

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

Similar topics

1
2491
by: Rune Froysa | last post by:
I have a fairly large program that uses a number of third-party modules. After a few hours the program eats several 100M of memory. Does Python provide any tools that can help in determining where the memory is used? Ideally, I would like to see a tool that can list all objects by memory-usage, but any tool that can return the number of...
3
2030
by: Guy | last post by:
Hi It might take me a little time to explain this but here goes. Firstly I'm not using the latest upto date python releases so my first plan is to try more upto date rels of python and win32 libs, as this has fixed problems for me in the past (Don't like doing this as it usally breaks stuff and sys admin are slow to update software,...
14
1525
by: Ömer KUL | last post by:
hi, i have a garbage collection problem. i have an application writen by vb.net, i am opening a form and in this form there is a big query. when i open the form, it takes 80 mb memory because of the data table. when i closed the form it is already taking 80 mb memory. where is garbage collection? i am waiting 30 minutes but memory usage is...
7
2285
by: Felix E. Klee | last post by:
Hi, why does the memory consumption of the program attached below increase steadily during execution? Shouldn't vector::reserve() allocate one large memory chunk of memory that doesn't change anymore? CPU: Pentium III Coppermine (Celeron) OS: Slackware LINUX 9.1 with kernel 2.4.22 Compiler: 3.2.3 Compile command: g++ -O0 -o foo foo.cpp
3
4132
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database periodically. What happens, is that the app reads the contents of a text file line by line into an ArrayList. Each element of the ArrayList is a string...
7
2458
by: Derrick | last post by:
I'm loading a boatload of data into a DataSet. The memory usage grows and grows for the app while loading that data. Calling GC.Collect() reduces the consumption slightly. When I minimize the app though, the usage goes to about 500k, and then grows when maximizing the app and working with DataSet. The DataSet still appears to have all data...
9
3246
by: Microsoft News Server | last post by:
Hi, I am currently having a problem with random, intermittent lock ups in my ASP.net application on our production server (99% CPU usage by 3 threads, indefinately). I currently use IIS Debug Tools to do a memory dump of the app when the lock up occurs, however the stack information is not very useful. I have just put a new build of our...
8
3029
by: mike2036 | last post by:
For some reason it appears that garbage collection is releasing an object that I'm still using. The object is declared in a module and instantiated within a class that is in turn instantiated by the mainline. The class that instantiated the object in question is definitely still in existence at the point garbage collection swoops in and...
1
366
by: Daniel | last post by:
i seem to be having memory issues, will deplying a release build instead of a debug build help with memory usage of my .net process?
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6621
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.