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.