WebBrowser control - High memory use

C

Cesar

Hello people. I'm having a Winform app that contains a webbrowser control
that keeps navigating from one page to another permanentrly to make some
tests. The problem I'm having is that after a while, the application is
using more than 100 or 150 Mb in RAM, and if I let it continue, it can leave
the system without memory. I've been watching in some pages that other
people has the same problem with this control when keep navigating for a
long period of time, but I've seen no answers at all about it...

Does anyone here has an answer for this control's behaviour?? I've tried
everything to reduce the memory use in the application but as the webbrowser
navigates more and more, the memory use of the application keeps
increasing...

Thanks in advance.

Regards.

Cesar.
 
K

kimiraikkonen

Hello people. I'm having a Winform app that contains a webbrowser control
that keeps navigating from one page to another permanentrly to make some
tests. The problem I'm having is that after a while, the application is
using more than 100 or 150 Mb in RAM, and if I let it continue, it can leave
the system without memory. I've been watching in some pages that other
people has the same problem with this control when keep navigating for a
long period of time, but I've seen no answers at all about it...

Does anyone here has an answer for this control's behaviour?? I've tried
everything to reduce the memory use in the application but as the webbrowser
navigates more and more, the memory use of the application keeps
increasing...

Thanks in advance.

Regards.

Cesar.

Cesar,
I've noticed that Webbrowser uses high amount of memory if webbrowser
has a heavy flash content. Please try to navigate some sites which
doesn't contain any flash content, then compare the results.

Thanks,

Onur Güzel
 
M

Michel Posseth [MCP]

The webbrowser control is a memory hungry control , i have ponce tryed the
Mozilla control instead but at that time it was indeed less demanding on
memory but it was verry unstable i do not know how this is now at this time
..

I had once understood that Mozilla and MS were planning a lightweight
control for showing html pages but i do not know what the status is for
these projects


A workaround could be to set the process working setsize of your project
once in a while ,than you get the same behaviour as minimizing and
maximizing the application by hand ( try it out and watch the memory usage )

as long as the application domain is loaded the memory will be reserved
for further processing


if your comp would run low on resources and the app does not need the memory
at the moment ( cause it is idle ,,, the memory would be given back and
needs to be reclaimed )


with a windows form application you can see this behavior to ( or did you
really thought a clean form needs about +- 25 megs in .Net ? )


there is a way you can bypass this behavior however it comes with a small
price ,,,,
i wrote once a remoting project , and had my customer complaining about the
memory consumption , so i digged a litle bit deeper and came with this
solution


my project ( wich is a singleton ) starts a timer that periodicly checks a
datetime var to see how manny time has passed after it was last called
if this intervall is >= 1 minute it will call SetProcessWorkingSetSize()
wich will trim the data usage to a minimum see below code ( sorry VB.Net
-) )


Private M_dtLastUsage As DateTime


Private oCallback As New TimerCallback(AddressOf OnTick)


Private oTimer As Threading.Timer


Public Sub OnTick(ByVal stateInfo As Object)


Dim DtCurrent As DateTime = Date.Now


Dim elapsed_time As TimeSpan


elapsed_time = DtCurrent.Subtract(M_dtLastUsage)


If elapsed_time.TotalMinutes >= 1 Then


oTimer.Dispose() : oTimer = Nothing


SetProcessWorkingSetSize()


End If


End Sub


Public Sub New()


M_dtLastUsage = Date.Now


If IsNothing(oTimer) Then


oTimer = New System.Threading.Timer(oCallback, Nothing,
System.TimeSpan.FromMinutes(0), System.TimeSpan.FromMinutes(1))


End If


End Sub


Private Declare Auto Function SetProcessWorkingSetSize Lib "kernel32.dll"
(ByVal procHandle As IntPtr, ByVal min As Int32, ByVal max As Int32) As
Boolean


Friend Sub SetProcessWorkingSetSize()


Try


Dim Mem As Process = Process.GetCurrentProcess()


SetProcessWorkingSetSize(Mem.Handle, -1, -1)


Catch ex As Exception


End Try


End Sub


The drawback of this method is that the framework needs to reclaim the
memory again so in theory your prog should be a few miliseconds slower as it
could be.


So it is more cosmetical as that it does really have a purpose as the prog
is actually gone to the swap same as a minimized application ( physical and
virtual memory thingy )





HTH

Michel Posseth
 
K

kimiraikkonen

The webbrowser control is a memory hungry control , i have ponce tryed the
Mozilla control instead but at that time it was indeed less demanding on
memory but it was verry unstable  i do not know how this is now at this time
.

I had once understood that Mozilla and MS were planning a lightweight
control for showing html pages but i do not know what the status is for
these projects

A workaround could be to set the process working setsize of your project
once in a while ,than you get the same behaviour as minimizing and
maximizing the application by hand ( try it out and watch the memory usage)

as long as the application domain is loaded the memory will be reserved
for further processing

if your comp would run low on resources and the app does not need the memory
at the moment ( cause it is idle ,,, the memory would be given back and
needs to be reclaimed )

with a windows form application you can see this behavior to ( or did you
really thought a clean form needs about +- 25 megs in .Net ? )

there is a way you can bypass this behavior however it comes with a small
price ,,,,
i wrote once a remoting project , and had my customer complaining about the
memory consumption , so i digged a litle bit deeper and came with this
solution

my project ( wich is a singleton ) starts a timer that periodicly checks a
datetime var to see how manny time has passed after it was last called
if this intervall is >= 1 minute it will call SetProcessWorkingSetSize()
wich will trim the data usage to a minimum see below code ( sorry VB.Net
-) )

Private M_dtLastUsage As DateTime

Private oCallback As New TimerCallback(AddressOf OnTick)

Private oTimer As Threading.Timer

Public Sub OnTick(ByVal stateInfo As Object)

Dim DtCurrent As DateTime = Date.Now

Dim elapsed_time As TimeSpan

elapsed_time = DtCurrent.Subtract(M_dtLastUsage)

If elapsed_time.TotalMinutes >= 1 Then

oTimer.Dispose() : oTimer = Nothing

SetProcessWorkingSetSize()

End If

End Sub

Public Sub New()

M_dtLastUsage = Date.Now

If IsNothing(oTimer) Then

oTimer = New System.Threading.Timer(oCallback, Nothing,
System.TimeSpan.FromMinutes(0), System.TimeSpan.FromMinutes(1))

End If

End Sub

Private Declare Auto Function SetProcessWorkingSetSize Lib "kernel32.dll"
(ByVal procHandle As IntPtr, ByVal min As Int32, ByVal max As Int32) As
Boolean

Friend Sub SetProcessWorkingSetSize()

Try

Dim Mem As Process = Process.GetCurrentProcess()

SetProcessWorkingSetSize(Mem.Handle, -1, -1)

Catch ex As Exception

End Try

End Sub

The drawback of this method is that the framework needs to reclaim the
memory again so in theory your prog should be a few miliseconds slower as it
could be.

So it is more cosmetical as that it does really have a purpose as the prog
is actually gone to the swap same as a minimized application  ( physicaland
virtual memory thingy )

HTH

Michel Posseth

"Cesar" <cesardemi @ yahoo . com . ar> schreef in bericht





- Show quoted text -

Michel,
I've also noticed that even i cannot navigate to a simple site using
Mozilla control, which crashes on navigation everytime.
http://groups.google.com/group/micr...bdd2c?hl=en&lnk=st&q=Mozilla#732f9f1188ebdd2c

.NET's Webbrowser is better in this case(but it's IE-based which means
a bit slow and crash-tended), but i wish there was a Mozilla control
(Gecko engine of course) that works like current Mozilla browser's
current release at least.

Thanks,

Onur
 
C

Cor Ligthert[MVP]

Michael,

Is this not the syntatical solution to let the taskmanager show the actual
in used memory.

That was why I asked what was the problem instead of every time, how do you
know that the memory consumption is high, the taskmanager is not meant as a
development tool.

Cor
 
C

Cor Ligthert [MVP]

synthetic

Cor Ligthert said:
Michael,

Is this not the syntatical solution to let the taskmanager show the actual
in used memory.

That was why I asked what was the problem instead of every time, how do
you know that the memory consumption is high, the taskmanager is not meant
as a development tool.

Cor
 
M

Michel Posseth

Cor Ligthert [MVP] schreef:
synthetic



Synthetic ??? wel if you read my message you see that i call it myself
Cosmetic :) , i also point out why

HTH


Michel
 
C

Cor Ligthert[MVP]

Michel,

You did, and I saw it, however I thought that you was meaning that there was
really some memory cleaned. AFAIK , is the cosmetic part only takskmanager.

:)

Cor

Michel Posseth said:
Cor Ligthert [MVP] schreef:
synthetic

Cor Ligthert said:
Michael,

Is this not the syntatical solution to let the taskmanager show the
actual in used memory.

That was why I asked what was the problem instead of every time, how do
you know that the memory consumption is high, the taskmanager is not
meant as a development tool.

Cor

"Michel Posseth [MCP]" <[email protected]> schreef in bericht
The webbrowser control is a memory hungry control , i have ponce tryed
the Mozilla control instead but at that time it was indeed less
demanding on memory but it was verry unstable i do not know how this
is now at this time .

I had once understood that Mozilla and MS were planning a lightweight
control for showing html pages but i do not know what the status is for
these projects


A workaround could be to set the process working setsize of your
project once in a while ,than you get the same behaviour as minimizing
and maximizing the application by hand ( try it out and watch the
memory usage )

as long as the application domain is loaded the memory will be reserved
for further processing


if your comp would run low on resources and the app does not need the
memory
at the moment ( cause it is idle ,,, the memory would be given back and
needs to be reclaimed )


with a windows form application you can see this behavior to ( or did
you
really thought a clean form needs about +- 25 megs in .Net ? )


there is a way you can bypass this behavior however it comes with a
small
price ,,,,
i wrote once a remoting project , and had my customer complaining about
the
memory consumption , so i digged a litle bit deeper and came with this
solution


my project ( wich is a singleton ) starts a timer that periodicly
checks a
datetime var to see how manny time has passed after it was last called
if this intervall is >= 1 minute it will call
SetProcessWorkingSetSize()
wich will trim the data usage to a minimum see below code ( sorry
VB.Net
-) )


Private M_dtLastUsage As DateTime


Private oCallback As New TimerCallback(AddressOf OnTick)


Private oTimer As Threading.Timer


Public Sub OnTick(ByVal stateInfo As Object)


Dim DtCurrent As DateTime = Date.Now


Dim elapsed_time As TimeSpan


elapsed_time = DtCurrent.Subtract(M_dtLastUsage)


If elapsed_time.TotalMinutes >= 1 Then


oTimer.Dispose() : oTimer = Nothing


SetProcessWorkingSetSize()


End If


End Sub


Public Sub New()


M_dtLastUsage = Date.Now


If IsNothing(oTimer) Then


oTimer = New System.Threading.Timer(oCallback, Nothing,
System.TimeSpan.FromMinutes(0), System.TimeSpan.FromMinutes(1))


End If


End Sub


Private Declare Auto Function SetProcessWorkingSetSize Lib
"kernel32.dll"
(ByVal procHandle As IntPtr, ByVal min As Int32, ByVal max As Int32) As
Boolean


Friend Sub SetProcessWorkingSetSize()


Try


Dim Mem As Process = Process.GetCurrentProcess()


SetProcessWorkingSetSize(Mem.Handle, -1, -1)


Catch ex As Exception


End Try


End Sub


The drawback of this method is that the framework needs to reclaim the
memory again so in theory your prog should be a few miliseconds slower
as it
could be.


So it is more cosmetical as that it does really have a purpose as the
prog
is actually gone to the swap same as a minimized application (
physical and
virtual memory thingy )





HTH

Michel Posseth


"Cesar" <cesardemi @ yahoo . com . ar> schreef in bericht
Hello people. I'm having a Winform app that contains a webbrowser
control
that keeps navigating from one page to another permanentrly to make
some
tests. The problem I'm having is that after a while, the application
is
using more than 100 or 150 Mb in RAM, and if I let it continue, it can
leave
the system without memory. I've been watching in some pages that other
people has the same problem with this control when keep navigating for
a
long period of time, but I've seen no answers at all about it...

Does anyone here has an answer for this control's behaviour?? I've
tried
everything to reduce the memory use in the application but as the
webbrowser
navigates more and more, the memory use of the application keeps
increasing...

Thanks in advance.

Regards.

Cesar.



Synthetic ??? wel if you read my message you see that i call it myself
Cosmetic :) , i also point out why

HTH


Michel
 
M

Michel Posseth [MCP]

Taskmanager shouldn`t be used to check for "reall" memory consumption of
..Net apps , however sorry for us the end user doesn`t know this and starts
complaining that is why i introduced the previous trick in some of my apps .




Michel





Cor Ligthert said:
Michel,

You did, and I saw it, however I thought that you was meaning that there
was really some memory cleaned. AFAIK , is the cosmetic part only
takskmanager.

:)

Cor

Michel Posseth said:
Cor Ligthert [MVP] schreef:
synthetic

"Cor Ligthert[MVP]" <[email protected]> schreef in bericht
Michael,

Is this not the syntatical solution to let the taskmanager show the
actual in used memory.

That was why I asked what was the problem instead of every time, how do
you know that the memory consumption is high, the taskmanager is not
meant as a development tool.

Cor

"Michel Posseth [MCP]" <[email protected]> schreef in bericht
The webbrowser control is a memory hungry control , i have ponce tryed
the Mozilla control instead but at that time it was indeed less
demanding on memory but it was verry unstable i do not know how this
is now at this time .

I had once understood that Mozilla and MS were planning a lightweight
control for showing html pages but i do not know what the status is
for these projects


A workaround could be to set the process working setsize of your
project once in a while ,than you get the same behaviour as minimizing
and maximizing the application by hand ( try it out and watch the
memory usage )

as long as the application domain is loaded the memory will be
reserved
for further processing


if your comp would run low on resources and the app does not need the
memory
at the moment ( cause it is idle ,,, the memory would be given back
and
needs to be reclaimed )


with a windows form application you can see this behavior to ( or did
you
really thought a clean form needs about +- 25 megs in .Net ? )


there is a way you can bypass this behavior however it comes with a
small
price ,,,,
i wrote once a remoting project , and had my customer complaining
about the
memory consumption , so i digged a litle bit deeper and came with this
solution


my project ( wich is a singleton ) starts a timer that periodicly
checks a
datetime var to see how manny time has passed after it was last called
if this intervall is >= 1 minute it will call
SetProcessWorkingSetSize()
wich will trim the data usage to a minimum see below code ( sorry
VB.Net
-) )


Private M_dtLastUsage As DateTime


Private oCallback As New TimerCallback(AddressOf OnTick)


Private oTimer As Threading.Timer


Public Sub OnTick(ByVal stateInfo As Object)


Dim DtCurrent As DateTime = Date.Now


Dim elapsed_time As TimeSpan


elapsed_time = DtCurrent.Subtract(M_dtLastUsage)


If elapsed_time.TotalMinutes >= 1 Then


oTimer.Dispose() : oTimer = Nothing


SetProcessWorkingSetSize()


End If


End Sub


Public Sub New()


M_dtLastUsage = Date.Now


If IsNothing(oTimer) Then


oTimer = New System.Threading.Timer(oCallback, Nothing,
System.TimeSpan.FromMinutes(0), System.TimeSpan.FromMinutes(1))


End If


End Sub


Private Declare Auto Function SetProcessWorkingSetSize Lib
"kernel32.dll"
(ByVal procHandle As IntPtr, ByVal min As Int32, ByVal max As Int32)
As
Boolean


Friend Sub SetProcessWorkingSetSize()


Try


Dim Mem As Process = Process.GetCurrentProcess()


SetProcessWorkingSetSize(Mem.Handle, -1, -1)


Catch ex As Exception


End Try


End Sub


The drawback of this method is that the framework needs to reclaim the
memory again so in theory your prog should be a few miliseconds slower
as it
could be.


So it is more cosmetical as that it does really have a purpose as the
prog
is actually gone to the swap same as a minimized application (
physical and
virtual memory thingy )





HTH

Michel Posseth


"Cesar" <cesardemi @ yahoo . com . ar> schreef in bericht
Hello people. I'm having a Winform app that contains a webbrowser
control
that keeps navigating from one page to another permanentrly to make
some
tests. The problem I'm having is that after a while, the application
is
using more than 100 or 150 Mb in RAM, and if I let it continue, it
can leave
the system without memory. I've been watching in some pages that
other
people has the same problem with this control when keep navigating
for a
long period of time, but I've seen no answers at all about it...

Does anyone here has an answer for this control's behaviour?? I've
tried
everything to reduce the memory use in the application but as the
webbrowser
navigates more and more, the memory use of the application keeps
increasing...

Thanks in advance.

Regards.

Cesar.



Synthetic ??? wel if you read my message you see that i call it myself
Cosmetic :) , i also point out why

HTH


Michel
 
J

John

Michel,

Task manager is entirely appropriate for checking *real*
memory use of a .net app. .net applications run as win32
processes just like any other--the "managed" application is
a concept created inside of the outer shell of the normal
unmanaged process.

Task manager can be used to show the user the .net app's
working set, private bytes, paged pool, etc.--these are all
very relevant when considering how much resources
are being used. It is true that task manager does not tell
you *everything* about resource use (one example
is that it doesn't show much memory is shared).

Think about it for a moment. From the managed perspective
the .net memory counters are more important, but what
*really* counts is the win32 memory/resources allocated by
the process. The end user is not running a "managed" OS
where the only memory allocated is "managed" memory.

You could have a .net application that uses a small
amount of managed memory (for example, say all of the
..net heaps add up to less than 20MB), but still have an
application that uses over a gig of RAM or more while it is
running.

This is something I have seen first hand when using the
activex web control. I recently created an application
with a single form that contained the activex web browser
control. Essentially all it does is call Refresh on the control
every 20 minutes. It steadily uses more and more memory
the longer it runs. The user is restricted to one web site that
contains no flash or other plugin content, however, it does
include a medium amount of javascript.

Such excessive use of memory eventually slows the
entire machine down due to hard paging and if not
corrected the app will crash (when it reaches 1-2Gigs).
This takes more than a week of uptime so I programmed
it to automatically terminate in the middle of the night to
prevent users from leaving it running too long.

I recommend you read chapter 7 "Memory Management"
as well as complete the experiments for a better understanding:

http://www.amazon.com/Microsoft-Windows-Internals-4th-Server/dp/0735619174/

Note that on Vista and Server 2008 the task manager
now defaults to showing Private Bytes for each process
instead of working set. Private Bytes will not be reduced
by the technique you posted.

The "solution" you posted at best will slow the app down
a little bit (imperceptable to the user), and at worst
(in memory-constrained circumstances) will make
certain that the app is even more sluggish than it would be.
This is because it will be more likely to have its pages
located in the page file.

J
 
J

John

Hi Cesar,

Which versions of the framework, IE, OS are
being used?

Please post a small sample that demonstrates the
problem.

I too have seen memory leaks with this control, but in
my case I am using the activex so that I can access
some additional events. Simply calling Refresh repeatedly
causes memory to rise unchecked.

Thanks.

J
 
C

Cor Ligthert [MVP]

I too have seen memory leaks with this control, but in
my case I am using the activex so that I can access
some additional events. Simply calling Refresh repeatedly
causes memory to rise unchecked.

Probably you did something wrong, however cover that with plaster does not
heal the wound.

Cor
 
L

Lloyd Sheen

Cor Ligthert said:
Michel,

You did, and I saw it, however I thought that you was meaning that there
was really some memory cleaned. AFAIK , is the cosmetic part only
takskmanager.

:)

Cor

Michel Posseth said:
Cor Ligthert [MVP] schreef:
synthetic

"Cor Ligthert[MVP]" <[email protected]> schreef in bericht
Michael,

Is this not the syntatical solution to let the taskmanager show the
actual in used memory.

That was why I asked what was the problem instead of every time, how do
you know that the memory consumption is high, the taskmanager is not
meant as a development tool.

Cor

"Michel Posseth [MCP]" <[email protected]> schreef in bericht
The webbrowser control is a memory hungry control , i have ponce tryed
the Mozilla control instead but at that time it was indeed less
demanding on memory but it was verry unstable i do not know how this
is now at this time .

I had once understood that Mozilla and MS were planning a lightweight
control for showing html pages but i do not know what the status is
for these projects


A workaround could be to set the process working setsize of your
project once in a while ,than you get the same behaviour as minimizing
and maximizing the application by hand ( try it out and watch the
memory usage )

as long as the application domain is loaded the memory will be
reserved
for further processing


if your comp would run low on resources and the app does not need the
memory
at the moment ( cause it is idle ,,, the memory would be given back
and
needs to be reclaimed )


with a windows form application you can see this behavior to ( or did
you
really thought a clean form needs about +- 25 megs in .Net ? )


there is a way you can bypass this behavior however it comes with a
small
price ,,,,
i wrote once a remoting project , and had my customer complaining
about the
memory consumption , so i digged a litle bit deeper and came with this
solution


my project ( wich is a singleton ) starts a timer that periodicly
checks a
datetime var to see how manny time has passed after it was last called
if this intervall is >= 1 minute it will call
SetProcessWorkingSetSize()
wich will trim the data usage to a minimum see below code ( sorry
VB.Net
-) )


Private M_dtLastUsage As DateTime


Private oCallback As New TimerCallback(AddressOf OnTick)


Private oTimer As Threading.Timer


Public Sub OnTick(ByVal stateInfo As Object)


Dim DtCurrent As DateTime = Date.Now


Dim elapsed_time As TimeSpan


elapsed_time = DtCurrent.Subtract(M_dtLastUsage)


If elapsed_time.TotalMinutes >= 1 Then


oTimer.Dispose() : oTimer = Nothing


SetProcessWorkingSetSize()


End If


End Sub


Public Sub New()


M_dtLastUsage = Date.Now


If IsNothing(oTimer) Then


oTimer = New System.Threading.Timer(oCallback, Nothing,
System.TimeSpan.FromMinutes(0), System.TimeSpan.FromMinutes(1))


End If


End Sub


Private Declare Auto Function SetProcessWorkingSetSize Lib
"kernel32.dll"
(ByVal procHandle As IntPtr, ByVal min As Int32, ByVal max As Int32)
As
Boolean


Friend Sub SetProcessWorkingSetSize()


Try


Dim Mem As Process = Process.GetCurrentProcess()


SetProcessWorkingSetSize(Mem.Handle, -1, -1)


Catch ex As Exception


End Try


End Sub


The drawback of this method is that the framework needs to reclaim the
memory again so in theory your prog should be a few miliseconds slower
as it
could be.


So it is more cosmetical as that it does really have a purpose as the
prog
is actually gone to the swap same as a minimized application (
physical and
virtual memory thingy )





HTH

Michel Posseth


"Cesar" <cesardemi @ yahoo . com . ar> schreef in bericht
Hello people. I'm having a Winform app that contains a webbrowser
control
that keeps navigating from one page to another permanentrly to make
some
tests. The problem I'm having is that after a while, the application
is
using more than 100 or 150 Mb in RAM, and if I let it continue, it
can leave
the system without memory. I've been watching in some pages that
other
people has the same problem with this control when keep navigating
for a
long period of time, but I've seen no answers at all about it...

Does anyone here has an answer for this control's behaviour?? I've
tried
everything to reduce the memory use in the application but as the
webbrowser
navigates more and more, the memory use of the application keeps
increasing...

Thanks in advance.

Regards.

Cesar.



Synthetic ??? wel if you read my message you see that i call it myself
Cosmetic :) , i also point out why

HTH


Michel

I believe this is the behaviour of the dll (can't remember the name) that is
used both by the .net component and COM. My morning ritual is to view local
online newpaper and RSS feeds which lead to other stories. I have been
watching this thread so this morning I looked and after about looking at 50
different pages the memory usage reported for IExplorer has increased from
about 32K to over 200K. It will never go down until I close IE. This is
constant behaviour. Lets say I download an item. While the dialog showing
the download is active I can close the GUI for IE but it is still there and
memory will increase as it downloads.

This leads me to believe that the only way to have the memory drop might be
to remove the control from the form and re-add it. Haven't tried this but
it might work.

LS
 
M

Michel Posseth [MCP]

This is discussed so often since the beta versions of .Net
and AFAIK it shows the workingset and you should use performance monitor to
watch for the "really used " values


Proof ??

create a new project containing one clean, now start this project in
compiled form ( exe ) look at the taskmanager
huh ??? i hear you say ,,, 25 + MB for only one simple form !!!

Now minimize the app , wait until the app memory drops , now maximize the
app and see the memory usage
seeing anny difference ??

You have just manually mimicked the behavior of my previously posted code
( it does exactly the same from code without the min / maximizing )
the program is swapped to the page file , and on reshow it needs to reclaim
physical memory .


The rest of the bla blah blah you might find in postings from years ago but
a quick google might bring them back

I could start a lecture here about application domains and how memory
management works in .Net but the point is you are wrong ( sorry ) :)

regards

Michel Posseth [MCP]
 
C

Cor Ligthert[MVP]

Michel,

Are you that guy who posted some years ago something as, "Thanks, I know it
does not help, but my System Admininstrator is happy now?

Cor

Michel Posseth said:
This is discussed so often since the beta versions of .Net
and AFAIK it shows the workingset and you should use performance monitor
to watch for the "really used " values


Proof ??

create a new project containing one clean, now start this project in
compiled form ( exe ) look at the taskmanager
huh ??? i hear you say ,,, 25 + MB for only one simple form !!!

Now minimize the app , wait until the app memory drops , now maximize the
app and see the memory usage
seeing anny difference ??

You have just manually mimicked the behavior of my previously posted code
( it does exactly the same from code without the min / maximizing )
the program is swapped to the page file , and on reshow it needs to
reclaim physical memory .


The rest of the bla blah blah you might find in postings from years ago
but a quick google might bring them back

I could start a lecture here about application domains and how memory
management works in .Net but the point is you are wrong ( sorry ) :)

regards

Michel Posseth [MCP]




John said:
Michel,

Task manager is entirely appropriate for checking *real*
memory use of a .net app. .net applications run as win32
processes just like any other--the "managed" application is
a concept created inside of the outer shell of the normal
unmanaged process.

Task manager can be used to show the user the .net app's
working set, private bytes, paged pool, etc.--these are all
very relevant when considering how much resources
are being used. It is true that task manager does not tell
you *everything* about resource use (one example
is that it doesn't show much memory is shared).

Think about it for a moment. From the managed perspective
the .net memory counters are more important, but what
*really* counts is the win32 memory/resources allocated by
the process. The end user is not running a "managed" OS
where the only memory allocated is "managed" memory.

You could have a .net application that uses a small
amount of managed memory (for example, say all of the
.net heaps add up to less than 20MB), but still have an
application that uses over a gig of RAM or more while it is
running.

This is something I have seen first hand when using the
activex web control. I recently created an application
with a single form that contained the activex web browser
control. Essentially all it does is call Refresh on the control
every 20 minutes. It steadily uses more and more memory
the longer it runs. The user is restricted to one web site that
contains no flash or other plugin content, however, it does
include a medium amount of javascript.

Such excessive use of memory eventually slows the
entire machine down due to hard paging and if not
corrected the app will crash (when it reaches 1-2Gigs).
This takes more than a week of uptime so I programmed
it to automatically terminate in the middle of the night to
prevent users from leaving it running too long.

I recommend you read chapter 7 "Memory Management"
as well as complete the experiments for a better understanding:

http://www.amazon.com/Microsoft-Windows-Internals-4th-Server/dp/0735619174/

Note that on Vista and Server 2008 the task manager
now defaults to showing Private Bytes for each process
instead of working set. Private Bytes will not be reduced
by the technique you posted.

The "solution" you posted at best will slow the app down
a little bit (imperceptable to the user), and at worst
(in memory-constrained circumstances) will make
certain that the app is even more sluggish than it would be.
This is because it will be more likely to have its pages
located in the page file.

J
 
M

Michel Posseth [MCP]

euhhhmmm ... not that i ( or google ) can recall at this moment ( could be )

I believe i was the one saying "my customers are happy now" as this was were
the problem that occured with me , customers complaining of the high memory
usage in taskmanager when we released a new VB.Net project to replace a VB6
prog

Funny to see that i indeed always called it a cosmetic problem ( google
brought this back since 2005 ) ,and indeed if a program really needs the
amount of process space it sure doesn`t help, calling the
setprocesworkingsetsize will only degrade the perfomance of the app

But keeping your customers happy is worth a price ,,,, :-|

Michel :)



Cor Ligthert said:
Michel,

Are you that guy who posted some years ago something as, "Thanks, I know
it does not help, but my System Admininstrator is happy now?

Cor

Michel Posseth said:
This is discussed so often since the beta versions of .Net
and AFAIK it shows the workingset and you should use performance monitor
to watch for the "really used " values


Proof ??

create a new project containing one clean, now start this project in
compiled form ( exe ) look at the taskmanager
huh ??? i hear you say ,,, 25 + MB for only one simple form !!!

Now minimize the app , wait until the app memory drops , now maximize the
app and see the memory usage
seeing anny difference ??

You have just manually mimicked the behavior of my previously posted code
( it does exactly the same from code without the min / maximizing )
the program is swapped to the page file , and on reshow it needs to
reclaim physical memory .


The rest of the bla blah blah you might find in postings from years ago
but a quick google might bring them back

I could start a lecture here about application domains and how memory
management works in .Net but the point is you are wrong ( sorry ) :)

regards

Michel Posseth [MCP]




John said:
Michel,

Task manager is entirely appropriate for checking *real*
memory use of a .net app. .net applications run as win32
processes just like any other--the "managed" application is
a concept created inside of the outer shell of the normal
unmanaged process.

Task manager can be used to show the user the .net app's
working set, private bytes, paged pool, etc.--these are all
very relevant when considering how much resources
are being used. It is true that task manager does not tell
you *everything* about resource use (one example
is that it doesn't show much memory is shared).

Think about it for a moment. From the managed perspective
the .net memory counters are more important, but what
*really* counts is the win32 memory/resources allocated by
the process. The end user is not running a "managed" OS
where the only memory allocated is "managed" memory.

You could have a .net application that uses a small
amount of managed memory (for example, say all of the
.net heaps add up to less than 20MB), but still have an
application that uses over a gig of RAM or more while it is
running.

This is something I have seen first hand when using the
activex web control. I recently created an application
with a single form that contained the activex web browser
control. Essentially all it does is call Refresh on the control
every 20 minutes. It steadily uses more and more memory
the longer it runs. The user is restricted to one web site that
contains no flash or other plugin content, however, it does
include a medium amount of javascript.

Such excessive use of memory eventually slows the
entire machine down due to hard paging and if not
corrected the app will crash (when it reaches 1-2Gigs).
This takes more than a week of uptime so I programmed
it to automatically terminate in the middle of the night to
prevent users from leaving it running too long.

I recommend you read chapter 7 "Memory Management"
as well as complete the experiments for a better understanding:

http://www.amazon.com/Microsoft-Windows-Internals-4th-Server/dp/0735619174/

Note that on Vista and Server 2008 the task manager
now defaults to showing Private Bytes for each process
instead of working set. Private Bytes will not be reduced
by the technique you posted.

The "solution" you posted at best will slow the app down
a little bit (imperceptable to the user), and at worst
(in memory-constrained circumstances) will make
certain that the app is even more sluggish than it would be.
This is because it will be more likely to have its pages
located in the page file.

J

Taskmanager shouldn`t be used to check for "reall" memory consumption
of .Net apps , however sorry for us the end user doesn`t know this and
starts complaining that is why i introduced the previous trick in some
of my apps .




Michel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top