Below is the line which I saw in the Sharepoint log.
12/15/2009 11:20:28.42 w3wp.exe (0x0F0C) 0x0668 SharePoint Foundation General
For my analysis, I opened the task manager and added a column PID into the Processes tab.
This PID will act as a link between the w3wp process and the application pool it is linked to.
Now open the command prompt.
set the path as C:\Windows\System32\inetsrv
Then type the command
appcmd list wp
This shall give you the list of application pool along with the PID.
Using the PID I was able to identify which application pool was consuming too much memory and was able to troubleshoot the issue.
For IIS 6.0, you can write the below command,
by going to the path C:\WINDOWS\system32.
Hope this helps someone who is having issues related to IIS worker process.