Investigate High CPU usage or Infinite Loop via WinDbg

12-10-2014

Confirm the Issue

We can investigate it using TaskMgr, if the CPU is around 25%, 50% or 100% (depends on how many cores you have, e.g. for 4 cores, 25% mean the program used up 1 core.)

If the CPU rate is not high but the program hangs, it probably indicates a deadlock.

Find the Thread

Note: WinDbg will suspend all thread, so we need to run the g command frequently if the program has something needs to run continuously, for example the program may disconnect from the server if suspended too long.

Preparation

Open WinDbg and the Command window(alt+1)

  • Attach to the process that you want to inspect using File-->Attach to a process(F6). And run g` in Command window immediately.
  • See the instructions here to setup the Symbol File Path and don’t forget to tick the reload check box. If you process cannot be suspended to long, then I would suggest just include the minimal necessary symbol files, especially you should exclude the Microsoft Symbol Server.

Read More »

Modular Design Patterns in JavaScript

05-10-2014

In this article, I’ll be describing the structure and benefits of an extended modular design patterns, that includes four principal member types:

  • public: members that can be accessed from anywhere
  • private: members that can only be accessed from inside the object
  • privileged: members that can only be directly accessed from inside the object, but which can be indirectly accessed from outside via a public method
  • protected: members that can only be accessed from inside the object or any of its modules.

This article is not about object-orientation, because the structure we’re going to create is a kind of singleton, which is a single-instance structure that cannot be instantiated more than once. In fact, it isn’t instantiated at all (in the sense of having a constructor), so it’s an object-based rather than object-oriented pattern.

For more about the difference between object-based and object-oriented programming, and an introduction to object-orientated programming in JavaScript, I’d recommend Ryan Frishberg’s article: JavaScript Object-Oriented Programming.

Read More »

Events in the ASP.NET Request Life Cycle

09-08-2014

copied from the Programming Microsoft ASP.NET 4 book, Page 32, Charpter 2, Part 1.

Events are fired in the following sequence:

BeginRequest

The ASP.NET HTTP pipeline begins to work on the request. For the first request ever in the lifetime of the application instance, this event reaches the application after Application_Start.

AuthenticateRequest

The request is being authenticated. ASP.NET and IIS integrated authentication modules subscribe to this event and attempt to produce an identity.

If no authentication module produced an authenticated user, an internal default authentication module is invoked to produce an identity for the unauthenticated user. This is done for the sake of consistency so that code doesn’t need to worry about null identities.

Read More »

JavaScript undefined VS null

28-03-2014

Copied from here

undefined与null的区别

大多数计算机语言,都有一个表示“无”的值。

比如,C语言的NULL,Java的null,Python的none,Ruby的nil。有点奇怪的是JavaScript语言居然有两个表示“无”的值:undefined和null。

这是为什么?

Read More »

How to pronounce symbols on keyboard?

21-11-2013

copied from here

~ “tilde” or “tweedle” or “squiggly line”. Also used as a “swung dash” and in mathematics with other signs to mean “approximately” and in logic sometimes used to mean “not”. See Tilde on wiki

``` “grave accent” or “stress mark”. See http://en.wikipedia.org/wiki/Grave_accen… .

! “exclamation point” or “exclamation mark’. Used to end an emphatic sentence. Also often used in computer languages to mean “not” and in mathematics to indicate “factorial’. See Exclamation on wiki.

@ “at sign” or “commercial at sign”. See it on wiki.

# “number sign” or “pound sign’ or “octothorpe” or “hash mark”

$ “dollar sign”, for example $29.00 would be read as “twenty-nine dollars’

Read More »