.net framework GC Heap Size

D

Dhruva Gopal

Hi,
I am wondering if there is a way to set a Max heap size
(for .Net Framework 1.0) so that GC kicks in once this
limit is reached. Also are there any known memory
consumption problems, with having .net framework 1.0 & 1.1
on the same system, with some applications using 1.0 and
others using 1.1?

Thanks in advance
Dhruva
 
D

Dhruva Gopal

Thanks Willy,
Couple of questions
1. What are the threshold levels for Gen0 and Gen1?
2. It would seem that Gen2 is never cleaned up. Is it
purged on First come first out basis when it gets to Gen2,
or does this grow uncontrollably? What we are seeing is
that the GC is very slow and lazy, and does not clean up
immediately, but over a long period of time, and it seems
that we run out of memory quickly. Another thing is that
this code was recompiled against VS7 from VS6 (Any known
issues there)? We seem to hit a point where an exception
is thrown in the .net process space for that service, due
to no memory being available.
3. Is there some way we can monitor memory consumption in
the .net runtime env, using a tool like performance
monitor in windows, to make monitor .net GC or just memory
consumption in general.

Thanks
You can't (and shouldn't) control the managed heap size,
this is something the CLR/GC takes care of.
The "CG heap" consists of three distinct areas (Named
Gen0, 1 & 2 heaps) plus a large object heap, each of the
Gen0-1 areas have a
certain threshold level at which the GC kicks in when that level has been reached.
The Gen0 area is the smallest and contains only objects
created after the last GC run, when the GC runs it will
collect Gen0 and
move live objects to the Gen1 area (this is called
promotion), unreachable objects will be removed (or put in
the finalizer queue)
and Gen0 will be compacted. When Gen1 reaches his
threshold during promotion, (old) live objects will move
to the Gen2 area (or
finalizer queue) and the Gen1 area will get compacted.
The net result is that Gen0 and Gen1 will never be larger
then their respective threshold levels, this is not the
case for gen2
which can grow beyond his threshold level up to the
systems available virtual memory (always less than 2GB or
3GB depending on the
 
W

Willy Denoyette [MVP]

Dhruva Gopal wrote:
|| Thanks Willy,
|| Couple of questions
|| 1. What are the threshold levels for Gen0 and Gen1?
|| 2. It would seem that Gen2 is never cleaned up. Is it
|| purged on First come first out basis when it gets to Gen2,
|| or does this grow uncontrollably? What we are seeing is
|| that the GC is very slow and lazy, and does not clean up
|| immediately, but over a long period of time, and it seems
|| that we run out of memory quickly. Another thing is that
|| this code was recompiled against VS7 from VS6 (Any known
|| issues there)? We seem to hit a point where an exception
|| is thrown in the .net process space for that service, due
|| to no memory being available.
|| 3. Is there some way we can monitor memory consumption in
|| the .net runtime env, using a tool like performance
|| monitor in windows, to make monitor .net GC or just memory
|| consumption in general.
||
|| Thanks
||

1. I guess the size of Gen0 is not fixed and depends on the HW (CPU-Cache) the system is running on.
Values I've seen range from 256Kb - 384Kb
Gen1 seems to be a multiple of gen0 (1Mb - 1.5 Mb)

2. If it looks like gen2 is never cleaned-up, I assume you are keeping your objects reachable (live references - fi in a collection)
this is a bug in your code, you shouldn't blame the GC, if this is the case the Gen2 area will grow until there is no more free VM.

3. You can use the performance monitor to watch the GC memory counters (no. of gen0,1 and 2 runs, number of promotions, size of
generations etc.)

You can also downoad the CLR memory profiler tool from www.gotdotnet.com.

Willy.
 
S

SR

Hi

Have a small related query. I have tried using both the
CLR Memory Profiler and the .NET Memory Profiler for
testing my ASP.Net apps. When i try to profile the
ASP.Net app, they shut down and restart the IIS(and the
asp.net wp), then a dialog box appears asking me to
access a page

But when i try to access any page from my IE, nothing
happens(guess the profiler hooks up the aspnet wp and
intercepts the calls). The page is not rendered on my
browser and i keep waiting.

If i cancel the dialog box also, nothing happens. would
appreciate a response on the same

regards,

sr

regards,

sr
 
S

SR

Hi Andreas

thanx a ton for a prompt and accurate reply. It is
working now.


regards,

sr
 
S

SR

Hi

Sorry to be a pest!!!! guess i replied too early. Now
the dialog box goes off, and it starts profiling(coz i
can use "Show Heap now" button). But the page does not get
loaded. takes a coupkle of minutes and throws this error.
Pls Help!!!! Im using CLR Profiler

Description: An error occurred during the compilation of a
resource required to service this request. Please review
the following specific error details and modify your
source code appropriately.

Compiler Error Message: The compiler failed with error
code 2000.



Show Detailed Compiler Output:


C:\WINNT\system32> "c:\winnt\microsoft.net\framework\v1.1.4
322
\vbc.exe" /t:library /utf8output /R:"c:\winnt\microsoft.net
\framework\v1.1.4322\temporary asp.net
files\MyWebApp\2a80fa94\f9c1e889\assembly\dl2\b756d817
\40b662cc_de54c301
\stb.lib69a.common.menulistctl.dll" /R:"c:\winnt\microsoft.
net\framework\v1.1.4322\temporary asp.net
files\MyWebApp\2a80fa94\f9c1e889\assembly\dl2\882740b0
\1e1daecd_de54c301
\kanyu.dll" /R:"c:\winnt\microsoft.net\framework\v1.1.4322
\temporary asp.net files\MyWebApp\2a80fa94\f9c1e889
\assembly\dl2\c4739f0b\001a9a45_85fdc201
\interop.sccodeasp.dll" /R:"c:\winnt\microsoft.net\framewor
k\v1.1.4322\temporary asp.net files\MyWebApp\2a80fa94
\f9c1e889\assembly\dl2\122dbdf3\9811fab8_de54c301
\stb.lib69a.common.notearea.dll" /R:"c:\winnt\assembly\gac\
system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.
dll" /R:"c:\winnt\microsoft.net\framework\v1.1.4322
\temporary asp.net files\MyWebApp\2a80fa94\f9c1e889
\assembly\dl2\4fbbf0b7\a8a01881_0058c301
\MyWebApp.dll" /R:"c:\winnt\assembly\gac\system.xml\1.0.500
0.0__b77a5c561934e089
\system.xml.dll" /R:"c:\winnt\assembly\gac\system.enterpris
eservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseser
vices.dll" /R:"c:\winnt\microsoft.net\framework\v1.1.4322
\temporary asp.net files\MyWebApp\2a80fa94\f9c1e889
\assembly\dl2\78a8bfb9\7c2b75c2_de54c301
\stb.lib69a.common.bankctl.dll" /R:"c:\winnt\microsoft.net\
framework\v1.1.4322\temporary asp.net
files\MyWebApp\2a80fa94\f9c1e889\assembly\dl2
\061cecfb\00fd7741_2cd7c101
\interop.comaprlib.dll" /R:"c:\winnt\microsoft.net\framewor
k\v1.1.4322\temporary asp.net files\MyWebApp\2a80fa94
\f9c1e889\assembly\dl2\b9e5a5f7\00f74903_5db0c001
\interop.comapq6lib.dll" /R:"c:\winnt\microsoft.net\framewo
rk\v1.1.4322\temporary asp.net files\MyWebApp\2a80fa94
\f9c1e889\assembly\dl2\80997874\5c40afa8_415ac301
\webjukyu.dll" /R:"c:\winnt\microsoft.net\framework\v1.1.43
22\temporary asp.net files\MyWebApp\2a80fa94\f9c1e889
\assembly\dl2\651ddcfa\2460a59c_de54c301
\stb.lib69a.common.entryerrordisplay.dll" /R:"c:\winnt\micr
osoft.net\framework\v1.1.4322\temporary asp.net
files\MyWebApp\2a80fa94\f9c1e889\assembly\dl2\f0800718
\32e2f472_415ac301
\jukyu.dll" /R:"c:\winnt\microsoft.net\framework\v1.1.4322
\temporary asp.net files\MyWebApp\2a80fa94\f9c1e889
\assembly\dl2\a3219c7c\06d5e6da_ff57c301
\common.dll" /R:"c:\winnt\microsoft.net\framework\v1.1.4322
\temporary asp.net files\MyWebApp\2a80fa94\f9c1e889
\assembly\dl2\dafa9ef7\9ab0dbc2_de54c301
\stb.lib69a.common.addressctl.dll" /R:"c:\winnt\microsoft.n
et\framework\v1.1.4322\temporary asp.net
files\MyWebApp\2a80fa94\f9c1e889\assembly\dl2
\3a8e214a\8ae736cd_de54c301
\stb.lib69a.common.menubarctl.dll" /R:"c:\winnt\microsoft.n
et\framework\v1.1.4322\temporary asp.net
files\MyWebApp\2a80fa94\f9c1e889\assembly\dl2
\1840b10c\767a7c12_df54c301
\webkanyu.dll" /R:"c:\winnt\assembly\gac\system.web.mobile\
1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /R:"c:\
winnt\microsoft.net\framework\v1.1.4322\temporary asp.net
files\MyWebApp\2a80fa94\f9c1e889\assembly\dl2\e38115f1
\0020e366_3216bf01
\interop.scdateasp.dll" /R:"c:\winnt\assembly\gac\microsoft
..web.ui.webcontrols\1.0.2.226__31bf3856ad364e35
\microsoft.web.ui.webcontrols.dll" /R:"c:\winnt\assembly\ga
c\system.data\1.0.5000.0__b77a5c561934e089
\system.data.dll" /R:"c:\winnt\microsoft.net\framework\v1.1
..4322\temporary asp.net files\MyWebApp\2a80fa94\f9c1e889
\assembly\dl2\26e55c49\ac1b1eae_de54c301
\usercontrol.dll" /R:"c:\winnt\microsoft.net\framework\v1.1
..4322\temporary asp.net files\MyWebApp\2a80fa94\f9c1e889
\assembly\dl2\ef8e3ff3\1a180c6a_de54c301
\stb.lib69a.common.dacsc.dll" /R:"c:\winnt\assembly\gac\sys
tem.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.se
rvices.dll" /R:"c:\winnt\assembly\gac\system.web\1.0.5000.0
__b03f5f7f11d50a3a\system.web.dll" /R:"c:\winnt\assembly\ga
c\system\1.0.5000.0__b77a5c561934e089
\system.dll" /out:"C:\WINNT\Microsoft.NET\Framework\v1.1.43
22\Temporary ASP.NET Files\MyWebApp\2a80fa94\f9c1e889
\nlr00ibl.dll" /D:DEBUG=1 /debug+ "C:\WINNT\Microsoft.NET\
Framework\v1.1.4322\Temporary ASP.NET
Files\MyWebApp\2a80fa94\f9c1e889\nlr00ibl.0.vb"


Microsoft (R) Visual Basic .NET Compiler version
7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322.573
Copyright (C) Microsoft Corporation 1987-2002. All rights
reserved.

vbc : Fatal error BC2000 : compiler initialization failed
unexpectedly: After the thread mode is set, it is not
possible to change.(Translated. Original Msg in
Japanese :))





Show Complete Compilation Source:


Line 1: '-----------------------------------------------
-------------------------------
Line 2: ' <autogenerated>
Line 3: ' This code was generated by a tool.
Line 4: ' Runtime Version: 1.1.4322.573
Line 5: '
Line 6: ' Changes to this file may cause incorrect
behavior and will be lost if
Line 7: ' the code is regenerated.
Line 8: ' </autogenerated>
Line 9: '-----------------------------------------------
-------------------------------
Line 10:
Line 11: Option Strict Off
Line 12: Option Explicit On
Line 13:
Line 14: Imports Microsoft.VisualBasic
Line 15: Imports System
Line 16: Imports System.Collections
Line 17: Imports System.Collections.Specialized
Line 18: Imports System.Configuration
Line 19: Imports System.Text
Line 20: Imports System.Text.RegularExpressions
Line 21: Imports System.Web
Line 22: Imports System.Web.Caching
Line 23: Imports System.Web.Security
Line 24: Imports System.Web.SessionState
Line 25: Imports System.Web.UI
Line 26: Imports System.Web.UI.HtmlControls
Line 27: Imports System.Web.UI.WebControls
Line 28:
Line 29: Namespace ASP
Line 30:
Line 31:
<System.Runtime.CompilerServices.CompilerGlobalScopeAttribu
te()> _
Line 32: Public Class Global_asax
Line 33: Inherits STB.Lib69A.MyWebApp.Global
Line 34:
Line 35: Private Shared __initialized As Boolean
= false
Line 36:
Line 37: Public Sub New()
Line 38: MyBase.New
Line 39: If (ASP.Global_asax.__initialized =
false) Then
Line 40: ASP.Global_asax.__initialized =
true
Line 41: End If
Line 42: End Sub
Line 43: End Class
Line 44: End Namespace
Line 45:





-----------------------------------------------------------
---------------------
Version Information: Microsoft .NET Framework
Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

regards,

sr
 

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