Memory leak in IE and/or Media Player

  • Thread starter Keith Franklin, MS MVP
  • Start date
K

Keith Franklin, MS MVP

Have application written with ASP.NET that serves HTML+TIME pages with
embedded .WMV files. As the .WMV files cycle IEXPLORE.EXE just grows and
grows and grows until crash.

On Windows XP we can kill the IEXPLORER.EXE process and restart it via .NET
System.Diagnostics.Process Namespace. On Windows XP embedded appears that we
cannot.

Any help would be great...


Here is code in Windows XPe that is failing...

//process.CloseMainWindow is the problem under XPe ....

{

process.StartInfo = new

System.Diagnostics.ProcessStartInfo(programName, programParameters);

while (!process.HasExited )

{

count++;

process.WaitForExit(1000);

if (count > resetWaitCount)

{

process.CloseMainWindow();

while (!process.HasExited)

{

System.Threading.Thread.Sleep(500);

}

process.Close();

System.Threading.Thread.Sleep(resetDelay);

process.Start();

count = 0;


}

}

process.Close();


this.Close();

}
 
K

Keith Franklin, MS MVP

Using Windows API and still doesnt work...
// on this version process.MainWindowHandle is the problem

[DllImport("User32.dll", EntryPoint="SendMessageW")]

static extern int SendMessageString(System.IntPtr hwnd, UInt32 wMsg,

UInt32 wparam, string lparam);

private const UInt32 WM_CLOSE = 0x0010;

{

process.StartInfo = new

System.Diagnostics.ProcessStartInfo(programName, programParameters);

while (!process.HasExited )

{

count++;

process.WaitForExit(1000);

if (count > resetWaitCount)

{

SendMessageString(process.MainWindowHandle, WM_CLOSE, 0, null);

while (!process.HasExited)

{

System.Threading.Thread.Sleep(500);

}

process.Close();

System.Threading.Thread.Sleep(resetDelay);

process.Start();

count = 0;


}

}

process.Close();


this.Close();

}
 
S

Slobodan Brcin \(eMVP\)

Hi Keith,

Why do you use .net for task that is simple as watching some process and restarting it?

Use C++ or some other unmanaged language with Win32 API CreateProcess.
Also consider assigning process to job so you can kill all its descendant processes as that they never existed: Win32 API
CreateJobObject

Anyhow regarding your question I can offer very limited help since I do not use .net.
There might be some features missing that your .net application try to use for purpose of process kill start.
Try using filemon and regmon utilities to see if there are some file or registry entries missing.

Also providing us with exact point of failure (unsuccessful call) and return value would be great so we can narrow the problem down.


Best regards,
Slobodan
 
S

Sean Gahan

Keith,
If you are going to use .net I think you will need to include performance
monitor/counter. Also, have you looked into com+, it can manage
applications to recycle after a specific period of time or limit the
resources that the app consumes. There was is a webcast on MSDN that covers
com+ called MSDN Architecture Webcast: Dave's Tour of .NET Middle-tier
Options - Level 300 :
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032257063&Culture=en-US

Regards,

Sean Gahan
 
B

Bill Baker

Hi Slobodan,

Keith asked me to reply.

Why are we using .Net? It is what we have been using for the rest of the
solution, but I will explore the C++ option. It will be fun to code directly
to the Win32API again :).

Here is the stack dump for the problem when running under XP embedded:

System.InvalidOperationException: Process performance counter is disabled,
so the requested operation cannot be performed.
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String
machineName, Boolean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos(String machineName)
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_MainWindowHandle()
at SIMLauncher.Form1.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Slobodan Brcin (eMVP) said:
Hi Keith,

Why do you use .net for task that is simple as watching some process and restarting it?

Use C++ or some other unmanaged language with Win32 API CreateProcess.
Also consider assigning process to job so you can kill all its descendant
processes as that they never existed: Win32 API
CreateJobObject

Anyhow regarding your question I can offer very limited help since I do not use .net.
There might be some features missing that your .net application try to use
for purpose of process kill start.
Try using filemon and regmon utilities to see if there are some file or registry entries missing.

Also providing us with exact point of failure (unsuccessful call) and
return value would be great so we can narrow the problem down.
Best regards,
Slobodan

"Keith Franklin, MS MVP" <[email protected]> wrote in
message news:[email protected]...
Using Windows API and still doesnt work...
// on this version process.MainWindowHandle is the problem

[DllImport("User32.dll", EntryPoint="SendMessageW")]

static extern int SendMessageString(System.IntPtr hwnd, UInt32 wMsg,

UInt32 wparam, string lparam);

private const UInt32 WM_CLOSE = 0x0010;

{

process.StartInfo = new

System.Diagnostics.ProcessStartInfo(programName, programParameters);

while (!process.HasExited )

{

count++;

process.WaitForExit(1000);

if (count > resetWaitCount)

{

SendMessageString(process.MainWindowHandle, WM_CLOSE, 0, null);

while (!process.HasExited)

{

System.Threading.Thread.Sleep(500);

}

process.Close();

System.Threading.Thread.Sleep(resetDelay);

process.Start();

count = 0;


}

}

process.Close();


this.Close();

}
 
K

Keith Franklin, MS MVP

We are just trying to find a workaround for a client side issue with
Internet Explorer and Media Player.

The true guts of the application is a web application that serves up
HTML+TIME which allows text overlays and transitions ontop of media files.

We discovered that over 10+ hours that IExplore.exe had grown huge. Some
memory wasnt released. So we looked around and found information that makes
it sound like a known problem with IE and Media Player. So the workaround
was to create a little client side application that kills IEexplorer.exe
periodically so the memory would be released and reopen IE. Whipped it up in
no time with .NET. Works fine on Windows XP but not on Windows XP Embedded.

End up with the following:

************** Exception Text **************
System.InvalidOperationException: Process performance counter is disabled,
so the requested operation cannot be performed.
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String
machineName, Boolean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos(String machineName)
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_MainWindowHandle()
at SIMLauncher.Form1.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)



Sean Gahan said:
Keith,
If you are going to use .net I think you will need to include performance
monitor/counter. Also, have you looked into com+, it can manage
applications to recycle after a specific period of time or limit the
resources that the app consumes. There was is a webcast on MSDN that covers
com+ called MSDN Architecture Webcast: Dave's Tour of .NET Middle-tier
Options - Level 300 :
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032257063&Culture=en-US

Regards,

Sean Gahan


Keith Franklin said:
Using Windows API and still doesnt work...
// on this version process.MainWindowHandle is the problem

[DllImport("User32.dll", EntryPoint="SendMessageW")]

static extern int SendMessageString(System.IntPtr hwnd, UInt32 wMsg,

UInt32 wparam, string lparam);

private const UInt32 WM_CLOSE = 0x0010;

{

process.StartInfo = new

System.Diagnostics.ProcessStartInfo(programName, programParameters);

while (!process.HasExited )

{

count++;

process.WaitForExit(1000);

if (count > resetWaitCount)

{

SendMessageString(process.MainWindowHandle, WM_CLOSE, 0, null);

while (!process.HasExited)

{

System.Threading.Thread.Sleep(500);

}

process.Close();

System.Threading.Thread.Sleep(resetDelay);

process.Start();

count = 0;


}

}

process.Close();


this.Close();

}
 
S

Slobodan Brcin \(eMVP\)

Hi Bill,

Read trough similar problems and workarounds:
http://groups.google.com/groups?hl=...a=group=microsoft.public.windowsxp.embedded.*

Hope that this helps.

Best regards,
Slobodan


Bill Baker said:
Hi Slobodan,

Keith asked me to reply.

Why are we using .Net? It is what we have been using for the rest of the
solution, but I will explore the C++ option. It will be fun to code directly
to the Win32API again :).

Here is the stack dump for the problem when running under XP embedded:

System.InvalidOperationException: Process performance counter is disabled,
so the requested operation cannot be performed.
at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String
machineName, Boolean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos(String machineName)
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_MainWindowHandle()
at SIMLauncher.Form1.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Slobodan Brcin (eMVP) said:
Hi Keith,

Why do you use .net for task that is simple as watching some process and restarting it?

Use C++ or some other unmanaged language with Win32 API CreateProcess.
Also consider assigning process to job so you can kill all its descendant
processes as that they never existed: Win32 API
CreateJobObject

Anyhow regarding your question I can offer very limited help since I do not use .net.
There might be some features missing that your .net application try to use
for purpose of process kill start.
Try using filemon and regmon utilities to see if there are some file or registry entries missing.

Also providing us with exact point of failure (unsuccessful call) and
return value would be great so we can narrow the problem down.
Best regards,
Slobodan

"Keith Franklin, MS MVP" <[email protected]> wrote in
message news:[email protected]...
Using Windows API and still doesnt work...
// on this version process.MainWindowHandle is the problem

[DllImport("User32.dll", EntryPoint="SendMessageW")]

static extern int SendMessageString(System.IntPtr hwnd, UInt32 wMsg,

UInt32 wparam, string lparam);

private const UInt32 WM_CLOSE = 0x0010;

{

process.StartInfo = new

System.Diagnostics.ProcessStartInfo(programName, programParameters);

while (!process.HasExited )

{

count++;

process.WaitForExit(1000);

if (count > resetWaitCount)

{

SendMessageString(process.MainWindowHandle, WM_CLOSE, 0, null);

while (!process.HasExited)

{

System.Threading.Thread.Sleep(500);

}

process.Close();

System.Threading.Thread.Sleep(resetDelay);

process.Start();

count = 0;


}

}

process.Close();


this.Close();

}
 
Top