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

Is there somewrong with CG?

I'm try to check how CG free up memory in intesive
allocation situation. But it seems that after an
collection, the memory is a bit larger than last time.

For example, from I run the code below for 100,000 cycle
after the first collection the size is '28,228'
after the last collection the size is '149,880'

This continue increase of memory worries me.
Do you know why this happens?

Thanks.

// The main flow ... ---------------------------

for(int i=0; i<100000; i++)
{
cv = new CV( 1024 );
cv = null;
Console.WriteLine( System.GC.GetTotalMemory(false ) );
}
// CV is defined as ... -----------------------
class CV
{
public CV( int n )
{
list = new byte[n];
}
public byte[] list;
}

Nov 15 '05 #1
3 1200
Peter <an*******@discussions.microsoft.com> wrote:
I'm try to check how CG free up memory in intesive
allocation situation. But it seems that after an
collection, the memory is a bit larger than last time.

For example, from I run the code below for 100,000 cycle
after the first collection the size is '28,228'
after the last collection the size is '149,880'

This continue increase of memory worries me.
Do you know why this happens?


You're giving false as the parameter to GetTotalMemory, which means it
*isn't* doing a garbage collection before reporting back. Change that
parameter to true and see if it helps.

Note that you don't need the line saying

cv = null;

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
> // The main flow ... ---------------------------

for(int i=0; i<100000; i++)
{
cv = new CV( 1024 );
cv = null;
Console.WriteLine( System.GC.GetTotalMemory(false ) );
try Console.WriteLine( System.GC.GetTotalMemory(true) );

Make it wait until the garbage collection finishes before printing the total
memory.

/m

}
// CV is defined as ... -----------------------
class CV
{
public CV( int n )
{
list = new byte[n];
}
public byte[] list;
}

Nov 15 '05 #3
If you want to know how the GC is working, use the CLR profiler - version
2.0 has just been released. You'll get a much better picture. Literally.

Sorry for the long link, but here it is (you'll need to unwrap it):
http://download.microsoft.com/downlo...20Profiler.EXE

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com
"Peter" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
I'm try to check how CG free up memory in intesive
allocation situation. But it seems that after an
collection, the memory is a bit larger than last time.

For example, from I run the code below for 100,000 cycle
after the first collection the size is '28,228'
after the last collection the size is '149,880'

This continue increase of memory worries me.
Do you know why this happens?

Thanks.

// The main flow ... ---------------------------

for(int i=0; i<100000; i++)
{
cv = new CV( 1024 );
cv = null;
Console.WriteLine( System.GC.GetTotalMemory(false ) );
}
// CV is defined as ... -----------------------
class CV
{
public CV( int n )
{
list = new byte[n];
}
public byte[] list;
}

Nov 15 '05 #4

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

Similar topics

2
by: Mikael Syska | last post by:
Hi, Google gives alot of hits on httpmodules but I can't seem to find any useful on my problem ... I have a site where I'm using my own auth system ... ( guess it could be better but its...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.