Tuesday, October 26, 2010

asp.net mvc, CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

after I located the Entity framework connection string, Unable to load the specified metadata resource. continued reading the professional asp.net mvc 2 to page 48. When I try to run the details page. /controller/details/validid
get the following error,

Compilation Error

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: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Source Error:

Line 170:
Line 171: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 172: public class views_dinners_details_aspx : System.Web.Mvc.ViewPage<LADinner.Models.Dinner>, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
Line 173:
Line 174: private static bool @__initialized;

Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_details.aspx.32d6c807.yjqx_sl8.0.cs    Line: 172
the stack trace shows when runtime try to compile the .aspx page using the csc.exe, missed one assembly reference System.Data.Entity.

then I click the detailed compiler output  , I get the following outputs. and Highlighted the System.Data.X assemblies. the error is right, there is no reference to System.Data.Entity.

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll"
/R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_global.asax.4lhx-qfz.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll"
/R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_3rrpychx.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Abstractions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Abstractions.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll"
/R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\assembly\dl3\452a723b\f0bfe800_2e75cb01\NerdDinner.DLL"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Web.Mvc\2.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Web.Entity.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll"
/R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Routing\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Routing.dll" /out:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_details.aspx.32d6c807.yjqx_sl8.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701 /warnaserror-  "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_details.aspx.32d6c807.yjqx_sl8.0.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_details.aspx.32d6c807.yjqx_sl8.1.cs"
Then I did some research. Though we added the assembly System.Data.Entity into our project. which means that those assembly are only for Runtime reference. For Compile time reference, We have to add the reference to System.web/Compilation/Assemblies in web.config, then the csc will pick up this settings

Like

<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>

Monday, October 25, 2010

Troubleshooting Entity framework connection string, Unable to load the specified metadata resource.

I was reading the Book called Professional MVC 2 , following the tutorial to Page 44.

When I run the application, /Details/id, which will invoke the Entity framework to do a DB query. No luck, get an strange error.

Line 37:         /// Initializes a new nerdDinnerEntities object using the connection string found in the 'nerdDinnerEntities' section of the application configuration file.
Line 38:         /// </summary>
Line 39:         public nerdDinnerEntities() : base("name=nerdDinnerEntities", "nerdDinnerEntities")
Line 40:         {
Line 41:             this.ContextOptions.LazyLoadingEnabled = true;

[MetadataException: Unable to load the specified metadata resource.]
   System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver) +2490148
   System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver) +170
   System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver) +8517824
   System.Data.Metadata.Edm.MetadataCache.SplitPaths(String paths) +271
   System.Data.Common.Utils.<>c__DisplayClass2.<Evaluate>b__0() +19
   System.Data.Common.Utils.Result.GetValue() +100
   System.Data.Common.Utils.Memoizer`2.Evaluate(TArg arg) +181
   System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections) +292
   System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection() +29
   System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor) +205
   System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) +27
   LADinner.Models.LaDinnerEntities..ctor() in C:\NerdDinner\Models\LaDinners.Designer.cs:39
   LADinner.Models.DinnerRepository..ctor() in C:\NerdDinner\Models\DinnerRepository.cs:10
   LADinner.Controllers.DinnersController..ctor() in C:\NerdDinner\Controllers\DinnersController.cs:14

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   System.Activator.CreateInstance(Type type) +6
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +491

[InvalidOperationException: An error occurred when trying to create a controller of type 'LADinner.Controllers.DinnersController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +628
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +204
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +193
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +160
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +80
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +45
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841400
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Then I check the web.config.  the connection string is there.

<connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.;Integrated Security=SSPI;database=aspnetdb;trusted_connection=true" providerName="System.Data.SqlClient"/>
    <add name="NerdDinnerEntities" connectionString="metadata=res://*/NerdDinner.Models.NerdDinners.csdl|res://*/NerdDinner.Models.NerdDinners.ssdl|res://*/NerdDinner.Models.NerdDinners.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;Initial Catalog=NerdDinner;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/></connectionStrings>

So the runtime will read some resource file embedded in the Assembly. So are the name correct?

I just run a ILDASM NerdDinner.DLL /out:a.il

c:\NerdDinner\bin>ildasm NerdDinner.dll /out:a.il

c:\NerdDinnerr\bin>dir
Volume in drive C is BOOTCAMP
Volume Serial Number is 7CA9-BE94

Directory of c:\NerdDinner\bin

10/25/2010  05:23 PM    <DIR>          .
10/25/2010  05:23 PM    <DIR>          ..
10/25/2010  05:23 PM           173,811 a.il
10/25/2010  05:23 PM               824 a.res
10/25/2010  05:19 PM            31,232 NerdDinner.dll
10/25/2010  05:19 PM            46,592 NerdDinner.pdb
10/25/2010  05:23 PM             2,298 Models.NerdDinners.csdl
10/25/2010  05:23 PM             1,205 Models.NerdDinners.msl
10/25/2010  05:23 PM             2,066 Models.NerdDinners.ssdl
               7 File(s)        258,028 bytes
               2 Dir(s)   5,624,713,216 bytes free

Here, for those resource file, Pay attantion to the filename. this is no Assmebly name as the prefix.
Models.NerdDinners.csdl Instead of NerdDinner.Models.NerdDinners.CSDL which is defined in the web.config

so remove the nerddinner in web.config , that’s the trick to fix the problem

<connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.;Integrated Security=SSPI;database=aspnetdb;trusted_connection=true" providerName="System.Data.SqlClient"/>
    <add name="NerdDinnerEntities" connectionString="metadata=res://*/NerdDinner.Models.NerdDinners.csdl|res://*/NerdDinner.Models.NerdDinners.ssdl|res://*/NerdDinner.Models.NerdDinners.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;Initial Catalog=NerdDinner;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/></connectionStrings>

Friday, October 22, 2010

Microsoft wse kerberos an invalid security token was provided

there is one WSE secured service  which is authenticated using the Kerberos token.   someday, I get this error. “an invalid security token was provided”

the error is very general , that means the TGT ticket is somehow invalid. Could be caused by time inconsistency, host mismatch, tons of reasons.

So how to get more inside error. like the com return come?
run Cordbg, and attach to the w3wp process. turn on unhandled exception.

ca e
a xxxxx
print $exception

 image

Print the Inner Exception Exception
  

p $exception._innerException

image

Here we get the detailed error.

The incoming Kerberos service ticket could not be validated. The LsaLogonUser call failed with the following message: The trust relationship between this workstation and the primary domain failed.
form the wse manual, you can check the reason is that  when the Kerberos target host name does not match the host name of the Web service that receives the SOAP message. Change the target host name to match the host name of the Web service.

you may try rejoin the server to domain. for me, that’s because the client send two tgt token.

wse 2 sp1 think that’s fine that one soap with two tgt token. for sp3, it will denied the request and throw the above error.

Wednesday, October 20, 2010

Microsoft SQL Server 2008 Setup SQL Server 2008 Setup requires .NET Framework 3.5 to be installed.

I get an error today, when I try to install sql server 2008 on one windows server 2008. The .net Framework 3.5  is there already. you can tell from the folder. C:\windows\MIcrosoft.net\Framework

image

image

the SQL 2008 requires windows installer 4.5. (you can tell from run “msiexec /?”

image

Go to this link to install the latest windows installer. http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5a58b56f-60b6-4412-95b9-54d056d6f9f4&displaylang=en

Then I go to %temp%, there is the setup log for sql server, also for all microsoft product. always check this folder for installation log.
there is one file called sqlsetup, here is the content.

10/20/2010 09:45:23.809 ======================================================================
10/20/2010 09:45:23.809 Setup launched
10/20/2010 09:45:23.809 Attempting to determine media source
10/20/2010 09:45:23.824 Media source value not specified on command line argument.
10/20/2010 09:45:23.824 Setup is launched from media directly so default the value to the current folder.
10/20/2010 09:45:23.824 Media source: E:\
10/20/2010 09:45:23.840 Attempt to determine media layout based on file 'E:\mediainfo.xml'.
10/20/2010 09:45:23.918 Media layout is detected as: Full
10/20/2010 09:45:23.934 Media LCID is detected as: 1033
10/20/2010 09:45:23.934 Local setup.exe not found, so continuing to run setup.exe from media.
10/20/2010 09:45:23.934 /? or /HELP or /ACTION=HELP specified: false
10/20/2010 09:45:23.949 Help display: false
10/20/2010 09:45:23.949 Checking to see if we need to install .Net version 3.5
10/20/2010 09:45:23.949 Determining the cluster status of the local machine.
10/20/2010 09:45:23.980 The local machine is not configured as a cluster node.
10/20/2010 09:45:23.996 Attempting to find media for .Net version 3.5
10/20/2010 09:45:23.996 Error: Cannot determine file version of .Net redist: 0x80004005
10/20/2010 09:51:44.615 .Net version 3.5 installation failed, so setup will close. Error code: 0x80004005
10/20/2010 09:51:44.631 Setup closed with exit code: 0x80004005
10/20/2010 09:51:44.631 ======================================================================

 

also I open the process monitor. to capture all fiel activity of setup.exe. , it try to read one setup file which is located in E:\x86\redist\DotNetFrameworks\dotNetFx35setup.exe

image

it’s not a valid PE file.

80004005 means  the file is broken.
so the final answer,  make sure you ISO checksum is correct. for me, just download a new ISO which works well.

Also Microsoft should prompt user a friendly error.

Monday, October 18, 2010

Install Squid cachemgr.cgi to IIS 7 (IIS comes with windows 7 or server 2008)

Copy the cachemgr.cgi to the IIS working folder.

1. turn on the CGI features for IIS 7 (Turn windows features on or Off )  , run “Optionalfeatures” in the command prompt.

image

after that, you should be able to see CGI in the IIS features set

image

2. add the handler mapping , Match extension .cgi file to cgi module. 
image

change the cgi permission to execute

image

3. setup permission to allow CGI execution.

Open the C:\Windows\System32\inetsrv\config\applicationHost.config, search isapiCgiRestriction Node.

<isapiCgiRestriction notListedIsapisAllowed="false” notListedCgisAllowed="True">

restart IIS. then you go.
image


FAQ,

If you see error

HTTP Error 404.3 - Not Found

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

you missed step 2

HTTP Error 404.2 - Not Found

The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.
you missed step 3

Thursday, October 14, 2010

Windbg, Script to Extract All HttpRequest URLs of a memory dump

Case, You get a Dump from a live proudction Server, (which has some performance problem for some real cusomters. ), at first you want to dump out all the requests that the server is handling.

Her is a how to tutorial.

#List all Requests

0:030> !DumpHeap -type System.Web.HttpRequest  -short
026a0a78
026d6510
026da4dc
0676ea70
0a6dad80
0a6dd820
0a8044d0
0a805efc
0a808d88
0a810c04
0e72b648
0e76e80c
0e76f228
0e7707ec
0e7780bc
0e77ebb0


here , we get the Request address. let’s pick any of them. like 0e7810bc
!do 0e7810bc
# Dump the object WebRequest

0:030> !do 0e77ebb0
Name: System.Web.HttpRequest
MethodTable: 6614c58c
EEClass: 65f50b50
Size: 172(0xac) bytes
(C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll)
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
6614e9b8  4001079        4 ...HttpWorkerRequest  0 instance 0e77e3ec _wr
6614ab4c  400107a        8 ...m.Web.HttpContext  0 instance 0e77eaf0 _context
793308ec  400107b        c        System.String  0 instance 0e77e61c _httpMethod
66126cf0  400107c       98         System.Int32  1 instance        2 _httpVerb
793308ec  400107d       10        System.String  0 instance 00000000 _requestType
6614776c  400107e       14 ...m.Web.VirtualPath  0 instance 0e77f92c _path
793308ec  400107f       18        System.String  0 instance 00000000 _rewrittenUrl
793043b8  4001080       a0       System.Boolean  1 instance        0 _computePathInfo
6614776c  4001081       1c ...m.Web.VirtualPath  0 instance 0e77ed34 _filePath
6614776c  4001082       20 ...m.Web.VirtualPath  0 instance 00000000 _currentExecutionFilePath
6614776c  4001083       24 ...m.Web.VirtualPath  0 instance 00000000 _pathInfo
793308ec  4001084       28        System.String  0 instance 0e781028 _queryStringText
793043b8  4001085       a1       System.Boolean  1 instance        0 _queryStringOverriden
7933335c  4001086       2c        System.Byte[]  0 instance 0e780e00 _queryStringBytes
793308ec  4001087       30        System.String  0 instance 0e77e670 _pathTranslated
793308ec  4001088       34        System.String  0 instance 00000000 _contentType
79332b38  4001089       9c         System.Int32  1 instance       -1 _contentLength
793308ec  400108a       38        System.String  0 instance 00000000 _clientTarget
793040bc  400108b       3c      System.Object[]  0 instance 00000000 _acceptTypes
793040bc  400108c       40      System.Object[]  0 instance 00000000 _userLanguages
660fe570  400108d       44 ...owserCapabilities  0 instance 0a7f9178 _browsercaps
7a5ec77c  400108e       48           System.Uri  0 instance 0e7810bc _url
7a5ec77c  400108f       4c           System.Uri  0 instance 00000000 _referrer
66153a28  4001090       50 ...b.HttpInputStream  0 instance 00000000 _inputStream
660fefa4  4001091       54 ...ClientCertificate  0 instance 00000000 _clientCertificate
79328f08  4001092       58 ...l.WindowsIdentity  0 instance 00000000 _logonUserIdentity
660fe224  4001093       5c ...tpValueCollection  0 instance 00000000 _params
660fe224  4001094       60 ...tpValueCollection  0 instance 0e780e10 _queryString
660fe224  4001095       64 ...tpValueCollection  0 instance 00000000 _form
66153264  4001096       68 ...pHeaderCollection  0 instance 00000000 _headers
660fe2f4  4001097       6c ...verVarsCollection  0 instance 00000000 _serverVariables
661519e4  4001098       70 ...pCookieCollection  0 instance 00000000 _cookies
66119620  4001099       74 ...ttpFileCollection  0 instance 00000000 _files
66153618  400109a       78 ...awUploadedContent  0 instance 00000000 _rawContent
793043b8  400109b       a2       System.Boolean  1 instance        0 _readEntityBody
793040bc  400109c       7c      System.Object[]  0 instance 00000000 _multipartContentElements
7933325c  400109d       80 System.Text.Encoding  0 instance 06698c34 _encoding
66113a6c  400109e       84 ...treamFilterSource  0 instance 00000000 _filterSource
7932e5e8  400109f       88     System.IO.Stream  0 instance 00000000 _installedFilter
6610b028  40010a0       a4 ...SimpleBitVector32  1 instance 0e77ec54 _flags
793308ec  40010a3       8c        System.String  0 instance 00000000 _AnonymousId
6614776c  40010a4       90 ...m.Web.VirtualPath  0 instance 0e77ed34 _clientFilePath
6614776c  40010a5       94 ...m.Web.VirtualPath  0 instance 00000000 _clientBaseDir
79330508  40010a1       d8        System.Object  0   shared   static s_browserLock
    >> Domain:Value  000d5050:NotInit  000f8758:0a6c8f30 00157af8:0a6db934 <<
793043b8  40010a2      7e0       System.Boolean  1   shared   static s_browserCapsEvaled
    >> Domain:Value  000d5050:NotInit  000f8758:1 00157af8:1 <<


in this request 0e77ebb0 , the _Url in red above is not null. the Address of the Url is

0e7810bc , this space is stored as the base object address 0e77ebb0 +48 Offset.
when you run dd 0e77ebb0 +48  l 1

0:030> dd 0e77ebb0 +48  l 1
0e77ebf8  0e7810bc

So, we can get the address of the url by run the caculating the baseaddress of request plus the offset.

then Inspect the Url object which is located in 0e7810bc

!do 0e7810bc

0:030> !do 0e7810bc
Name: System.Uri
MethodTable: 7a5ec77c
EEClass: 7a4554f8
Size: 40(0x28) bytes
(C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll)
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
793308ec  4001b52        c        System.String  0 instance 0e781110 m_String
793308ec  4001b53       10        System.String  0 instance 00000000 m_originalUnicodeString
7a5ec934  4001b54       14     System.UriParser  0 instance 0669fc44 m_Syntax
793308ec  4001b55       18        System.String  0 instance 00000000 m_DnsSafeHost
7aa1303c  4001b56        4        System.UInt64  1 instance 37624152064 m_Flags
7a5ec9fc  4001b57       1c   System.Uri+UriInfo  0 instance 0e78117c m_Info
793043b8  4001b58       20       System.Boolean  1 instance        0 m_iriParsing
793308ec  4001b47      644        System.String  0   shared   static UriSchemeFile
    >> Domain:Value  000d5050:NotInit  000f8758:0e6a1434 00157af8:0e6a1434 <<
793308ec  4001b48      648        System.String  0   shared   static UriSchemeFtp
    >> Domain:Value  000d5050:NotInit  000f8758:0e6a141c 00157af8:0e6a141c <<
793308ec  4001b49      64c        System.String  0   shared   static UriSchemeGopher
    >> Domain:Value  000d5050:NotInit  000f8758:0e6a1450 00157af8:0e6a1450 <<
793308ec  4001b4a      650        System.String  0   shared   static UriSchemeHttp
    >> Domain:Value  000d5050:NotInit  000f8758:0e6a13e4 00157af8:0e6a13e4 <<
793308ec  4001b4b      654        System.String  0   shared   static UriSchemeHttps
    >> Domain:Value  000d5050:NotInit  000f8758:0e6a1400 00157af8:0e6a1400 <<


then dumpobject  0e781110 , which you can get this value from base address+C

0:030> !do 0e781110
Name: System.String
MethodTable: 793308ec
EEClass: 790ed64c
Size: 106(0x6a) bytes
(C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: http://localhost:88/WebSite/Default.aspx?q=1
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
79332b38  4000096        4         System.Int32  1 instance       45 m_arrayLength
79332b38  4000097        8         System.Int32  1 instance       44 m_stringLength
793315cc  4000098        c          System.Char  1 instance       68 m_firstChar
793308ec  4000099       10        System.String  0   shared   static Empty
    >> Domain:Value  000d5050:0a6901d0 000f8758:0a6901d0 00157af8:0a6901d0 <<
7933151c  400009a       14        System.Char[]  0   shared   static WhitespaceChars
    >> Domain:Value  000d5050:0a690728 000f8758:0e690a0c 00157af8:02697aac <<



here we get url. whole process is get the addressof Request, then get the address of URL by inspecting the memory  offset 48. Get the URl Address B. then inspect B+offset c, get the string value.

When can put all into a foreach command.

0:030> .foreach   (req {!DumpHeap -type System.Web.HttpRequest -short}) { .foreach /pS 1 (a {dd ${req}+48  l 1}) {.echo ${a}; !do poi(${a}+c)} }
026d342c
Name: System.String
MethodTable: 793308ec
EEClass: 790ed64c
Size: 106(0x6a) bytes
(C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: http://localhost:88/WebSite/Default.aspx?q=1
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
79332b38  4000096        4         System.Int32  1 instance       45 m_arrayLength
79332b38  4000097        8         System.Int32  1 instance       44 m_stringLength
793315cc  4000098        c          System.Char  1 instance       68 m_firstChar
793308ec  4000099       10        System.String  0   shared   static Empty
    >> Domain:Value  000d5050:0a6901d0 000f8758:0a6901d0 00157af8:0a6901d0 <<
7933151c  400009a       14        System.Char[]  0   shared   static WhitespaceChars
    >> Domain:Value  000d5050:0a690728 000f8758:0e690a0c 00157af8:02697aac <<
00000000
Invalid parameter poi(00000000+c)
026dc358
Name: System.String
MethodTable: 793308ec
EEClass: 790ed64c
Size: 106(0x6a) bytes
(C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: http://localhost:88/WebSite/Default.aspx?q=3
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
79332b38  4000096        4         System.Int32  1 instance       45 m_arrayLength
79332b38  4000097        8         System.Int32  1 instance       44 m_stringLength
793315cc  4000098        c          System.Char  1 instance       68 m_firstChar
793308ec  4000099       10        System.String  0   shared   static Empty
    >> Domain:Value  000d5050:0a6901d0 000f8758:0a6901d0 00157af8:0a6901d0 <<
7933151c  400009a       14        System.Char[]  0   shared   static WhitespaceChars
    >> Domain:Value  000d5050:0a690728 000f8758:0e690a0c 00157af8:02697aac <<
067705a8
Name: System.String
MethodTable: 793308ec
EEClass: 790ed64c
Size: 98(0x62) bytes


here we get all the ongoing request urls.
if you get errors like

00000000
Invalid parameter poi(00000000+c)
00000000
Invalid parameter poi(00000000+c)
00000000
Invalid parameter poi(00000000+c)
00000000
Invalid parameter poi(00000000+c)

that means the application itself never query the url of the request. by default the _Url is keeped as binary format in the IISworkrequest.

image

Wednesday, October 13, 2010

Windbg tips, Dump all Objects with the same type loop with .foreach

Case, there are a lot Memory get used by some objects with the same type.  let’s say the type is String here, how can we dump all those strings.

how to, list all those object ids, and run DumpObject.   .for each

here is a Demo.

static void Main(string[] args)
      {
          string[] buffer = new string[10];
          for (int i = 0; i < 10; i++)
          {
              //big strings
              buffer[i] = new string('-', 20*1024);
          }
          Console.ReadLine();
      }

//List all those string whose size is over 20K

!DumpHeap -type System.String -min 20000

0:004> !DumpHeap -type System.String -min 20000
Address       MT     Size
012d93bc 793308ec    32180    
013155e4 793308ec    45832    
0133d5a8 793308ec    32180    
013597c4 793308ec    40980    
013637d8 793308ec    40980    
0136d7ec 793308ec    40980    
01377800 793308ec    40980    
01381814 793308ec    40980    
0138b828 793308ec    40980    
0139583c 793308ec    40980    
0139f850 793308ec    40980    
013a9864 793308ec    40980    
013b3878 793308ec    40980


the address Column displays the ddress for each string. Let me pick up the red one.

0:004> !do 013b3878
Name: System.String
MethodTable: 793308ec
EEClass: 790ed64c
Size: 40978(0xa012) bytes
(C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
79332b38  4000096        4         System.Int32  1 instance    20481 m_arrayLength
79332b38  4000097        8         System.Int32  1 instance    20480 m_stringLength
793315cc  4000098        c          System.Char  1 instance       2d m_firstChar
793308ec  4000099       10        System.String  0   shared   static Empty
    >> Domain:Value  001599c8:012d1198 <<
7933151c  400009a       14        System.Char[]  0   shared   static WhitespaceChars
    >> Domain:Value  001599c8:012d18cc <<

If you want to List all the strings , only display ID.

0:004> !DumpHeap -type System.String -min 20000 -short
012d93bc
013155e4
0133d5a8
013597c4
013637d8
0136d7ec
01377800
01381814
0138b828
0139583c
0139f850
013a9864
013b3878

 

then run loop .foreach.

.foreach (address  {!DumpHeap -type System.String -min 20000 -short }) {!do ${address} }
//will display all strings

Tuesday, October 12, 2010

.NET GC Large Objects, CPU intensive.

you may get the following symbol, “CPU is high , around 40-50% percent, Memory usage is reasonable or very low”

cause? could be the GC problem. which is CPU intensive. ( I have a lot Memory, why bothering a GC? the depends. short story, If you put some big objects or big arrays over 85K, CLR will treat that differently. )

given a basic application.

int less85k = 8 * 1024;
int more85k = 86 * 1024;

string lessstring = new string('l', less85k);
string moresring = new string('m', more85k);

two string will go to different GC zone. one is regular gc, another one is Large object gc.

you can tell from windbg, or sos extension.

image

when I run !DumpHeap –type System.String –min 10000

image

Obje A is in the generation 2 regular GC ( you can tell from obj address, 012d is betwen 12d000 and 012e0030)

when you run !do 012d9bd4  to dump the object, you can tell it’s the smaller string.

image

for the big one. !do 022d3250

image

Now they are in different GC zone. If there are a lot string operations. let’s we keep create the big strings.

for (int i = 0; i < 10; i++)
        {
            ThreadPool.QueueUserWorkItem(
                sender =>
                {
                    while (true)
                    {
                        string moresring = new string('m', more85k);
                    }
                }
                );
        }

 

CPU is high, Memory usage is low.

image

a lot CPU kernel time.  Big object GC caused more context switching for CPU.

image

TURN on the performance counter, chose the clr memory. there are center amount of GC time.

image

open the live stack via windbg.

image

pick one anyone like 05 ~5s !clrstack

image

kb for unmanged stack (allocate large objects and adjust the limit clr)

0:005> kb
ChildEBP RetAddr  Args to Child             
010af7f4 79f926b3 0237f2c0 0002b028 010af8c0 mscorwks!WKS::gc_heap::adjust_limit_clr+0xd6
010af88c 79f926ce 010af8c0 0002b018 00000003 mscorwks!WKS::gc_heap::try_allocate_more_space+0x5bb
010af8a0 79f9a2dc 010af8c0 0002b018 00000003 mscorwks!WKS::gc_heap::allocate_more_space+0x11
010af8e0 79eee84a 0002b012 00000000 0015ef30 mscorwks!WKS::gc_heap::allocate_large_object+0x54
010af8f8 79e73291 001804c8 0002b012 00000000 mscorwks!WKS::GCHeap::Alloc+0x66
010af914 79e7d8d4 0002b012 00000000 00000000 mscorwks!Alloc+0x60
010af950 79e99056 00015801 fe2369b0 00000000 mscorwks!SlowAllocateString+0x29
010af9f4 792e1040 00000000 012de030 012ddc74 mscorwks!FramedAllocateString+0xa1
010afa2c 792c9dff 012ddc8c 792e019f 00982010 mscorlib_ni+0x221040
010afa34 792e019f 00982010 012ddc74 012ddc8c mscorlib_ni+0x209dff
010afa48 792ca363 012ddc74 00000000 012ddc74 mscorlib_ni+0x22019f
010afa60 792ca1f9 25f33da1 010afaa4 00180488 mscorlib_ni+0x20a363
010afa78 79e71b4c 77e69433 77e6945f 010afb08 mscorlib_ni+0x20a1f9
010afa88 79e821b1 00000000 00000000 010afc10 mscorwks!CallDescrWorker+0x33
010afb08 79e82cfa 00000000 00000000 010afc10 mscorwks!CallDescrWorkerWithHandler+0xa3
010afb28 79e82d3b 00000000 00000000 010afc10 mscorwks!DispatchCallBody+0x1e
010afb8c 79e82da9 00000000 00000000 010afc10 mscorwks!DispatchCallDebuggerWrapper+0x3d
010afbc0 79f2fd65 00000000 00000000 010afc10 mscorwks!DispatchCallNoEH+0x51
010afc1c 79e9845f 00000000 00000001 00000000 mscorwks!QueueUserWorkItemManagedCallback+0x59
010afc30 79e983fb 010afd0c 010afcb8 79f7759b mscorwks!Thread::DoADCallBack+0x32a

 

if we try the same code for small objects.

for (int i = 0; i < 10; i++)
        {
            ThreadPool.QueueUserWorkItem(
                sender =>
                {
                    while (true)
                    {
                        string lessstring = new string('l', less85k);
                    }
                }
                );
        }

CPU is also High, but more on usertime

image

 

0:014> !clrstack
OS Thread Id: 0x1fac (14)
ESP       EIP    
03a1f5a4 79f9255a [HelperMethodFrame: 03a1f5a4]
03a1f5fc 792e1040 System.String.CtorCharCount(Char, Int32)
03a1f618 00ea01bd ConsoleApplication10.Program+<>c__DisplayClass2.<Main>b__0(System.Object)
03a1f634 792c9dff System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Object)
03a1f63c 792e019f System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
03a1f654 792ca363 System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
03a1f668 792ca1f9 System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
03a1f7f8 79e71b4c [GCFrame: 03a1f7f8]
0:014> kb
ChildEBP RetAddr  Args to Child             
03a1f42c 79f926b3 015b8cc0 00004020 00187fd0 mscorwks!WKS::gc_heap::adjust_limit_clr+0xd6
03a1f4c4 79f926ce 00187fd0 00004014 00000000 mscorwks!WKS::gc_heap::try_allocate_more_space+0x5bb
03a1f4d8 79f92769 00187fd0 00004014 00000000 mscorwks!WKS::gc_heap::allocate_more_space+0x11
03a1f4f8 79e73291 00187fd0 00004012 00000000 mscorwks!WKS::GCHeap::Alloc+0x3b
03a1f514 79e7d8d4 00004012 00000000 00000000 mscorwks!Alloc+0x60
03a1f550 79e99056 00002001 47a58a5d 00000000 mscorwks!SlowAllocateString+0x29
*** WARNING: Unable to verify checksum for C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\9adb89fa22fd5b4ce433b5aca7fb1b07\mscorlib.ni.dll
03a1f5f4 792e1040 00000000 012d7468 012d72d0 mscorwks!FramedAllocateString+0xa1
03a1f62c 792c9dff 012d72e8 792e019f 00982010 mscorlib_ni+0x221040
03a1f634 792e019f 00982010 012d72d0 012d72e8 mscorlib_ni+0x209dff
03a1f648 792ca363 012d72bc 00000000 012d72d0 mscorlib_ni+0x22019f
03a1f660 792ca1f9 25f82416 03a1f6a4 00187f90 mscorlib_ni+0x20a363
03a1f678 79e71b4c 77e69433 00150178 03a1f708 mscorlib_ni+0x20a1f9
03a1f688 79e821b1 00000000 00000000 03a1f810 mscorwks!CallDescrWorker+0x33
03a1f708 79e82cfa 00000000 00000000 03a1f810 mscorwks!CallDescrWorkerWithHandler+0xa3
03a1f728 79e82d3b 00000000 00000000 03a1f810 mscorwks!DispatchCallBody+0x1e
03a1f78c 79e82da9 00000000 00000000 03a1f810 mscorwks!DispatchCallDebuggerWrapper+0x3d
03a1f7c0 79f2fd65 00000000 00000000 03a1f810 mscorwks!DispatchCallNoEH+0x51
03a1f81c 79e9845f 00000000 00000001 00000000 mscorwks!QueueUserWorkItemManagedCallback+0x59
03a1f830 79e983fb 03a1f90c 03a1f8b8 79f7759b mscorwks!Thread::DoADCallBack+0x32a
03a1f8c4 79e98321 03a1f90c 47a586a9 00000001 mscorwks!Thread::ShouldChangeAbortToUnload+0xe3

just regular space allocation.

Monday, October 11, 2010

Identifying High CPU in GC caused By Json.NET Newtonsoft.Json.JsonReader.ParseString windbg

just get a high CPU case, Here is the way I narrow down the issues.

Problems: IIS get high CPU, even only small requests been forwarded to this server.

Answer: something wrong with the json.net, need to update the dll to latest version. http://json.codeplex.com/releases/view/50552

receipt to locate the problem.

Create a Memory Dump using the DebugDiag. http://www.microsoft.com/downloads/en/details.aspx?FamilyID=28bd5941-c458-46f1-b24d-f60151d875a3&displaylang=en

Also copy 3 dlls from production server to debug machine. follow

windbg:PDB symbol for mscorwks.dll not loaded when you debug dump of .net app or silverlight apps and How to configure WinDbg to run other versions of the .NET

to make sure the windbg pick up the right extensions.

What are those CPU threads doing? pick up the smoking gun threads

 

.time

0:055> .time
Debug session time: Thu Oct  7 09:23:37.000 2010 (GMT-7)
System Uptime: 0 days 7:13:54.707
Process Uptime: 0 days 7:10:08.000
  Kernel time: 0 days 23:44:52.000
  User time: 0 days 14:44:43.000

How about CPU threads , time spending.

!runaway

0:055> !runaway
User Mode Time
  Thread       Time
  32:930       0 days 1:44:11.109
  30:914       0 days 1:25:19.343
  34:940       0 days 1:16:02.093
  39:9e4       0 days 1:14:45.171
  31:938       0 days 1:14:08.984
  25:17ec      0 days 1:13:34.687
  33:6f4       0 days 1:12:02.671
  29:17fc      0 days 1:10:18.765
  40:9e8       0 days 1:09:28.203
  27:17f4      0 days 1:08:49.453
  37:7d0       0 days 1:07:50.390
  35:3e8       0 days 1:07:15.718
  36:998       0 days 1:07:10.687
  38:9d8       0 days 1:07:08.968
  28:17f8      0 days 0:59:04.093
  26:17f0      0 days 0:58:39.687
  65:1f74      0 days 0:14:17.843
  44:ce8       0 days 0:12:41.843
  52:d2c       0 days 0:12:38.515
  53:d30       0 days 0:12:34.359
  55:d38       0 days 0:11:53.093
  54:d34       0 days 0:11:44.203
  45:cec       0 days 0:11:42.875
  51:d28       0 days 0:11:36.093
  62:1b74      0 days 0:11:20.921
  46:cf0       0 days 0:11:13.515


the top 15 threads using a lot CPU cycles. What are they doing Now.

Switch the first thread, #32
~32s
!clrstack

0:032> !clrstack
OS Thread Id: 0x930 (32)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process

thread 32 is not a managed thread. but that doesn’t exclude our CLR code from the bad lists.

then run kb

kb

0:032> kb
ChildEBP RetAddr  Args to Child             
02f3f688 7c827d29 77e61d1e 00000358 00000000 ntdll!KiFastSystemCallRet
02f3f68c 77e61d1e 00000358 00000000 00000000 ntdll!ZwWaitForSingleObject+0xc
02f3f6fc 79e8c5f9 00000358 ffffffff 00000000 kernel32!WaitForSingleObjectEx+0xac
02f3f740 79e8c52f 00000358 ffffffff 00000000 mscorwks!PEImage::LoadImage+0x1af
02f3f790 79e8c54e ffffffff 00000000 00000000 mscorwks!CLREvent::WaitEx+0x117
02f3f7a4 79fd4417 ffffffff 00000000 00000000 mscorwks!CLREvent::Wait+0x17
02f3f7e8 79fcfd70 000f49b8 00000006 00000000 mscorwks!SVR::t_join::join+0xae
02f3f828 79fcf35d 00000002 00000000 000f49b8 mscorwks!SVR::gc_heap::mark_phase+0x176
02f3f854 79fcf77d 00000000 ffffffff 000f49b8 mscorwks!SVR::gc_heap::gc1+0x46
02f3f874 79fcf283 00000000 00000000 000f49b8 mscorwks!SVR::gc_heap::garbage_collect+0x246
02f3f898 79f23b6a 00000000 00000000 00000000 mscorwks!SVR::gc_heap::gc_thread_function+0x6a
02f3ffb8 77e6482f 000f49b8 00000000 00000000 mscorwks!SVR::gc_heap::gc_thread_stub+0x92
02f3ffec 00000000 79f23b1c 000f49b8 00000000 kernel32!BaseThreadStart+0x34


thread 32 is working on GC, which is CPU intensive.
then try other top cpu intensive threads they did the same thingg, Working on GC

0:038> kb
ChildEBP RetAddr  Args to Child             
030bf088 7c827d29 77e61d1e 00000358 00000000 ntdll!KiFastSystemCallRet
030bf08c 77e61d1e 00000358 00000000 00000000 ntdll!ZwWaitForSingleObject+0xc
030bf0fc 79e8c5f9 00000358 ffffffff 00000000 kernel32!WaitForSingleObjectEx+0xac
030bf140 79e8c52f 00000358 ffffffff 00000000 mscorwks!PEImage::LoadImage+0x1af
030bf190 79e8c54e ffffffff 00000000 00000000 mscorwks!CLREvent::WaitEx+0x117
030bf1a4 79fd4417 ffffffff 00000000 00000000 mscorwks!CLREvent::Wait+0x17
030bf1e8 79fcfd70 000fc048 00000006 00000000 mscorwks!SVR::t_join::join+0xae
030bf228 79fcf35d 00000002 00000000 000fc048 mscorwks!SVR::gc_heap::mark_phase+0x176
030bf254 79fcf77d 00000000 ffffffff 000fc048 mscorwks!SVR::gc_heap::gc1+0x46
030bf274 79fcf283 00000000 00000000 000fc048 mscorwks!SVR::gc_heap::garbage_collect+0x246
030bf298 79f23b6a 00000000 030bf2c0 7c82cce3 mscorwks!SVR::gc_heap::gc_thread_function+0x6a
030bffb8 77e6482f 000fc048 00000000 00000000 mscorwks!SVR::gc_heap::gc_thread_stub+0x92
030bffec 00000000 79f23b1c 000fc048 00000000 kernel32!BaseThreadStart+0x34


search gc context, there is a lot

x mscorwks!SVR::gc_heap::*
image

So all those busy threads is working on GC, which thread triggered the Demand for GC? that will be the next question.

time to check out those green threads. which consumes rest quota of the CPU

65:1f74      0 days 0:14:17.843
  44:ce8       0 days 0:12:41.843
  52:d2c       0 days 0:12:38.515
  53:d30       0 days 0:12:34.359
  55:d38       0 days 0:11:53.093
  54:d34       0 days 0:11:44.203
  45:cec       0 days 0:11:42.875
  51:d28       0 days 0:11:36.093
  62:1b74      0 days 0:11:20.921
  46:cf0       0 days 0:11:13.515

 

Switch to thread 65 or 44
~65s
!clrstack
image

the stack means in the shopping cart page, it will use json.net to parse some value. in our case, the values is stord in Cookie.

Is this tread is asking for more memory. It is, Let me show you why?

kb
image

1, it try to create a big array, then NO space. ask for runtime to issue a gc.

then for us, we get very big value to parse. there are some thing wrong with the cookie system. Update to the new version will get better performance

anyway, for Json Deserialization. first make sure the size is reasonable before you parse it.

Thursday, October 7, 2010

Install Ruby on windows 7 tutorial

Download the MSI file from ruby site. http://rubyinstaller.org/downloads/, (there is no 64 bit version of ruby, so just chose the version which is stable. dont care about 32/64 issue)Click to install.
image

Select the folder , and check to make sure it put ruby folder into system PATH.

image

That’s it. when done, you can run “ruby –v” in the command prompt.

image

Also you can run the ruby interactive console. By running “IRB” in the command line

 image

for the folder structure, one is Lib, another is the bin directory.

image

in the bin directory. there are several utilities. ruby.exe and several bootstarper for different purpose.

for example, the irb.bat which is the ruby interactive console.

just been wrapped as “ruby bin\irb” , where irb is a ruby script.

image

Saturday, October 2, 2010

Uninstall /backup inspect Iphone/Ipad/IPOD Application.

Iphone system is a security sandbox, if you are curious about what's inside the box. like how does one APP handle the cached data, How does Iphone keep the Contact list? How to uninstall one application manually. or run the update manually. Or even whether one app Use the adobe library or Not (like netflix use the micrososoft playread or not, does nook use the adobe sdk or not) ? I will give one general approch to answer those questions.

Always you need the following steps to answser those questions.

  • Jailbreak the Iphone.
  • Install OpenSSH like utility that you can connect to the Iphone system.
  • use winscp/scp/ssh client to view the file structure , or export/import what ever you like.

Jailbreak the Iphone/IPAD/IPOD

enter jailbreakme.com in the safari browser. And slide to jailbreak. this might take several minutes.
 

Once done, restart the iphone, you will see the cydia application.

IMG_0546

Install OpenSSH

cydia is a appstore like app center, Search and install OpenSSH. click install to load this application.

IMG_0548

use winscp/scp/ssh client to view the file structure , or export/import what ever you like.

after you install the OpenSSH. make sure iphone and you pc connect to the same wireless. you can tell the iphone IP from the wifi setting

image

here, 192.168.0.108 is the iphone IP.

you can tell 192.168.0.108 22 and make sure the openssh service is running.

image

Search all the application that installed one the Iphone.

I will use Putty as the ssh client. ( enter root as the username, and apline as the password to login )

image

List all the apps

Run command “ find / –iname *.app”

image

you will noticed System application is under the directory of /private/var/stash/Applications

and thrid party application is under /private/var/mobile/Applications.

image

for example, you can go the the highlight folder to explore the American express application.

there are a few images in the folder.

image

when you go one upper level.

image

you will find the Documents library, always that’s the place to keep user information, like settings, preference. if you want to do some back, just copy this folder out.

with that, you can use WINSCP to view and import/export files between iphone and you pc

image

if you want to update one app manually, just get the new .app and copy it to the folder where previous version resides.

for the nook application, you can tell it use sqllite to keep some metadata

image

when you open the nook bin , search adboe

image

it does use the adobe content server.

Uninstall one application.

just find the app and delete it. pretty simple.

 
Locations of visitors to this page