473,396 Members | 1,907 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,396 software developers and data experts.

I'm tired, I don't know if is my problem or if is a framework problem

I was posted this in other newsgroup but i never see in the list.
-----------------------------------------------------------------

My problem is...
I have an application (Console Application). Every second it use more and
more memory, with the .NET memory profiler I see that thousands of (Byte,
Regex, String etc) instances I have in memory.

But, when I run the GC.Collect and the the GC.WaitForPendingFinalizers
manualy, the memory is released and the number of instances of the classes
mentioned are redused to 10, 5, 15 etc

My Question is, If I have a memory leak, no matter if I run or nor the
GC.Collect and the GC.WaitForPendingFinalizer the memory should not be
release, because in teory is referenced for any other instance.

Assuming that I haven't a memory leak, what is my problem?
Why the GC wait for a manual run of GC.WaitForPendingFinalizers to release
the memory?
I have a windows 2003 multiprocessor with 512 of RAM.
If I not run manually the GC.WaitForPendingFinalizer the use of memory of my
app go to 400 MB and the virtual memory go to 700 MB, after it, a "low disk
space" messsage appear next to the clock in the task bar. I think that is
the same message "Low virtual memory" of the windows 2000.

Thanks a lot.

AA


Jul 19 '05 #1
1 1997
"Anibal Acosta" <aa@personal.net.py> wrote in message
news:Ox****************@TK2MSFTNGP11.phx.gbl...
Assuming that I haven't a memory leak, what is my problem?
Why the GC wait for a manual run of GC.WaitForPendingFinalizers to release
the memory?


use this class instead of the Regex class. I have only implement IsMatch.
use the same pattern ("using ..") for any other

using System;
using System.Reflection;
using System.Text.RegularExpressions;

public class RegexDisposable : Regex, IDisposable {
private static MethodInfo unCache;

public RegexDisposable(string pattern) : base(pattern) {}

public static new bool IsMatch(string input, string pattern) {
using(RegexDisposable r = new RegexDisposable(pattern)){
return r.IsMatch(input);
}
}

#region IDisposable Members

public void Dispose() {
if ( unCache == null ) {
lock(typeof(RegexDisposable)) {
if ( unCache == null ) {
unCache = typeof(Regex).GetMethod("UncacheCode",
BindingFlags.NonPublic | BindingFlags.Instance );
}
}
}
if ( unCache != null ) {
unCache.Invoke(this,null);
GC.SuppressFinalize(this);
}
}
#endregion
}
Jul 19 '05 #2

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

Similar topics

6
by: AbeR | last post by:
I'm an intermediate/novice (I've probably developed a half dozen ASP.NET apps at this point) ASP.NET C# developer at this point and am totally strumped by a client's setup. I am developing this...
1
by: Anibal Acosta | last post by:
I was posted this in other newsgroup but i never see in the list. ----------------------------------------------------------------- My problem is... I have an application (Console...
12
by: AFN | last post by:
I am running the code below to generate XML from a data table. But some fields in the data table are Null for every record. Suppose field5 has a null database value. I would expect to see: ...
3
by: Sky Sigal | last post by:
I coming unglued... really need some help. 3 days chasing my tail all over MSDN's documentation ...and I'm getting nowhere. I have a problem with TypeConverters and storage of expandableobjects...
14
by: Thomas Andersson | last post by:
Hi, I am so so tired of getting this error message when I try to open a web project or create a new one: The web server reported the following error when attempting to create ot open the web...
1
by: Roy | last post by:
Hey all, Yeah, I'm tired of the same old, boring datagrids. Does anyone out there have links on how to "spruce up" a datagrid using style sheets or something else so that they aren't as blocky...
61
by: John Baker | last post by:
When declaring an integer, you can specify the size by using int16, int32, or int64, with plain integer being int32. Is integer the accepted default in the programming community? If so, is...
1
by: nickjaffe | last post by:
Hi all, I've spent literally hours trying to figure this one out. I'm re-developing an app from vb6 to vb.net, and I cannot get my XML code working. I've just started using .NET. I'm tired,...
1
by: ccon67 | last post by:
In a win32 project I have several compile errors for the resource *.rc. The first fews errors look like this error RC2144 : PRIMARY LANGUAGE ID not a number error RC2135 : file not found:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.