categories

Blogroll

Subscribe via email

Enter your email address:

Delivered by FeedBurner

Subscribe Now: Feed

Showing posts with label Troubleshooting. Show all posts
Showing posts with label Troubleshooting. Show all posts

Tuesday, July 3, 2007

Winsock2 LSP Corruption & Fix


Figure: Winsock 2 Architecture (Source: Microsoft)
Introduction
Microsoft Windows Winsock provides network socket facility for Applications via Service Provider Interface (SPI) and is extensible via Layered Service Provider (LSP). A LSP is a Dynamic Link Library (DLL) that uses Winsock Application Programming Interfaces (APIs) to insert itself into the TCP/IP stack from where it can intercept and modify all the TCP/IP inbound/outbound internet traffic taking place between Internet and the Application accessing internet. In simple words, LSP typically handles low-level Internet-related tasks, and data is passed through a chain of these programs on its way to and from the Internet.

Winsock LSPs are available for a wide range of useful purposes, e.g. internet access control, web content filtering, traffic analysis etc. The Winsock API prvoides a mecahnism for layering providers to implement only higher level custom communication functions. The layering order of all providers is kept in the Winsock Catalog.

About LSP Corruption
One of the major issue with LSPs is that if they are removed or unregistered improperly or if the LSP is malformed (buggy), it could result in corruption of the Winsock catalog in the registry, the entire TCP/IP stack would break, potentially resulting in a loss of all network connectivity. Lot of Spyware, Adware & Malware may insert themselves as an LSP in the network stack to spy on the habits and data of the user and may forward all of the user's internet traffic to an unauthorized external site for data mining purpose. The problem can also be caused by any improperly written Layered Service Provider software, or the deletion of any LSP program's files. If you uninstall/delete these malformed programs (spyware, adware), it may happen that you won't be able to access Internet. This is due to the broken LSP chain.

LSP Corruption FIX
If you are running Windows XP (Service Pack 2), there are two new Netsh commands available (although Winsock self heals in XP SP2).
1. netsh winsock show catalog
This command displays the list of all Winsock LSPs that are installed on the computer. You can go through the list to find malformed LSPs.

2. netsh winsock reset catalog
This command resets the Winsock catalog to the default configuration. This can be useful if a malformed LSP is installed that results in loss of network connectivity. While use of this command can restore network connectivity, it should be used with care because any previously installed LSPs will need to be re-installed.

If you are runing Windows XP (Without Service Pack 2), you would need to manually repair winsock by deleting the corrupted registry keys and then reinstall/reset the TCP/IP protocol.

Step 1: Delete the corrupted registry keys
Warning: Backup your registry before you edit it. For more information about how to back up the registry, click here
1. Click Start, and then click Run.
2. In the Open box, type regedit, and then click OK.
3. In Registry Editor, locate the following keys, right-click each key, and then click Delete:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Winsock
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Winsock2
4. When you are prompted to confirm the deletion, click Yes.
5. Restart the computer after you delete the Winsock keys. Doing so causes the Windows XP operating system to create new shell entries for those two keys.
Note: If you do not restart the computer after you delete the Winsock keys, the next step does not work correctly.

Step 2: Reset TCP/IP Protocol Stack
1. Run the following Netsh Command
netsh int ip reset c:\resetlog.txt
2. Restart your computer.

When you run the reset command, it rewrites following pertinent registry keys that are used by the Internet Protocol (TCP/IP) stack to reach the same result as the removal and the reinstallation of the protocol.
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\
SYSTEM\CurrentControlSet\Services\DHCP\Parameters\

Other Operating Systems
If your Operating System is Windows 98, 98SE or ME, You can download the following program to fix Winsock LSP.
Winsockfix
LSP-Fix
XPTCPREP

AddThis Social Bookmark Button

Tuesday, May 29, 2007

PermGen OutOfMemory


If you are frustrated with Tomcat, JBoss, any other Java Application Server dying with an OutOfMemory Error every few times you redeploy your Java application code or if you have recently installed a new application in your Stable Java Environment and your Tomcat, JBoss is giving you hiccups by intermittently Crashing with OutOfMemory Errors , then keep on reading as I would like to share my thoughts with you as I have experienced the same issue.

You have checked that your Server has lot of Physical RAM, even JVM Heap Memory has been allocated a significant amount of Physical Memory, your Garbage Collection (GC) is tuned properly but you are still getting OutOfMemory error. I am not going to discuss about Java Virtual Machine (JVM) Memory model and Garbage Collection (GC) as this is out of the scope of this article. But you can read the details here

Introduction
SUN Java has a Generational garbage collector. Permanent Generation holds reflective data (meta-data) of the JVM itself, such as class and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized independently from the other generations.[Ref: SUN Java website ]

The Error
SUN Java website says that the default size of PermGen (64 MB for Server) is adequate in most cases but programs that load many classes may need a larger permanent generation. When you hot deploy/redeploy your web application, the WAR file is unpacked and its class definition are loaded into the JVM. These classes are never unloaded and they end up in the Permanent Generation. Now, if you hot deploy your application few times or install a new web application with large code base that loads up lot of class files, the default PermGen space get quickly filled and is never Garbage Collected (by standard GC) causing java.lang.OutOfMemoryError: PermGen.

But I have large JVM Heap
It doesn't matter how high is your overall -Xmx heap setting and how much memory you have on the machine. PermGen size i.e. PermSize is additional to the -Xmx value on the JVM Options.

The FIX
There is no garbage collection by standard garbage collection in Permanent Generation. Although concurrent garbage collector can collect in PermGen but this is beyond the scope of this article. I would be rather focussing on increasing the PermGen size.
  1. Make sure your Server has enough Physical RAM (considering the allocation to JVM Heap -Xmx).
  2. Use larger PermGen size using the Options -XX:PermSize= and -XX:MaxPermSize=
  3. e.g. Set the maximum permanent generation size using -XX:MaxPermSize=164m Option.
MaxPermSize allows for the JVM to be able to grow the PermSize to the amount specified. Initially when the JVM is loaded, the MaxPermSize will still be the default value (64mb for Server) but will not actually take up that amount until it is needed. But, if you want to Set a new initial perm size on Sun JVM, you can use -XX:PermSize=164m Option when starting the JVM.

Conclusion
  • The PermGen default size can be a bottleneck in your Web Applications that dynamically generate and load many classes.
  • The PermGen parameters discussed above when applied to the JVM that runs your application server, considerably reduces the chances of running into a PermGen OutOfMemoryError.


AddThis Social Bookmark Button