memory leak - garbage collection?

  • Thread starter Thread starter stuforman
  • Start date Start date
S

stuforman

I have a vb programming, running 200+ SSIS

it gets through most, but towards the end gives me "Insufficient
Memory" errors

my code looks like:

CallSSIS("SalFut_new_ISP")
CallSSIS("SalSalall_ISP")
CallSSIS("SalSalid_ISP")
CallSSIS("SalSvc2a_ISP")
CallSSIS("TempHome_ISP")
CallSSIS("wclsUsIteam_ISP")

End Sub

Sub CallSSIS(ByVal SSISname As String)

Dim pkgLocation As String
Dim pkg As New Package
Dim app As New Application
Dim pkgResults As DTSExecResult

Console.WriteLine(SSISname)
pkgLocation = _
"C:\Documents and Settings\sforman\My Documents\Visual
Studio 2005\Projects\" + SSISname + "\" + SSISname + "\Package.dtsx"
pkg = app.LoadPackage(pkgLocation, Nothing)
pkgResults = pkg.Execute()
Console.WriteLine("Done")
pkgLocation = Nothing
pkg = Nothing
pkgResults = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
End Sub

can anyone help?

thanks a lot,

Stu
 
you could try this for memory leaks

Private Declare Function SetProcessWorkingSetSize Lib
"kernel32.dll" (ByVal process As IntPtr, ByVal minimumWorkingSetSize
As Integer, ByVal maximumWorkingSetSize As Integer) As Integer

Public Shared Sub FlushMemory()
'GC.Collect()
'GC.WaitForPendingFinalizers()
If (Environment.OSVersion.Platform = PlatformID.Win32NT) Then
Dim p As Process = Process.GetCurrentProcess
SetProcessWorkingSetSize(p.Handle, -1, -1)
p.Dispose()
End If
End Sub
 
you could try this for memory leaks

Private Declare Function SetProcessWorkingSetSize Lib
"kernel32.dll" (ByVal process As IntPtr, ByVal minimumWorkingSetSize
As Integer, ByVal maximumWorkingSetSize As Integer) As Integer

Public Shared Sub FlushMemory()
'GC.Collect()
'GC.WaitForPendingFinalizers()
If (Environment.OSVersion.Platform = PlatformID.Win32NT) Then
Dim p As Process = Process.GetCurrentProcess
SetProcessWorkingSetSize(p.Handle, -1, -1)
p.Dispose()
End If
End Sub

ok - i'll give it a shot. thanks for the suggestion
 
stuforman said:
Sub CallSSIS(ByVal SSISname As String)

Dim pkgLocation As String
Dim pkg As New Package
Dim app As New Application
Dim pkgResults As DTSExecResult

Console.WriteLine(SSISname)
pkgLocation = _
"C:\Documents and Settings\sforman\My Documents\Visual
Studio 2005\Projects\" + SSISname + "\" + SSISname + "\Package.dtsx"
pkg = app.LoadPackage(pkgLocation, Nothing)
pkgResults = pkg.Execute()
Console.WriteLine("Done")

Up to here, I'd say things look OK, but ...
pkgLocation = Nothing
pkg = Nothing
pkgResults = Nothing

Unless these classes have COM components underlying them, then setting
these references to Nothing isn't going to do anything useful and
certainly won't release any additional resources they might be holding
on to.

Do any of these classes have a Dispose() method? If so, call it!
Objects holding unmanaged resources (and, I'd suggest, it's likely that
these ones do) should implement the IDisposable pattern and calling
their Dispose method /will/ free up those resources.

HTH,
Phill W.
 
Barkingmadscot said:
you could try this for memory leaks

Private Declare Function SetProcessWorkingSetSize Lib
"kernel32.dll" (ByVal process As IntPtr, ByVal minimumWorkingSetSize
As Integer, ByVal maximumWorkingSetSize As Integer) As Integer

Public Shared Sub FlushMemory()
'GC.Collect()
'GC.WaitForPendingFinalizers()
If (Environment.OSVersion.Platform = PlatformID.Win32NT) Then
Dim p As Process = Process.GetCurrentProcess
SetProcessWorkingSetSize(p.Handle, -1, -1)
p.Dispose()
End If
End Sub

Make sure you know what 'SetProcessWorkingSetSize' is really doing:

The working set of an application is trimmed when its top-level window is
minimized
<URL:http://support.microsoft.com/?scid=kb;EN-US;293215>
 
Up to here, I'd say things look OK, but ...


Unless these classes have COM components underlying them, then setting
these references to Nothing isn't going to do anything useful and
certainly won't release any additional resources they might be holding
on to.

Do any of these classes have a Dispose() method? If so, call it!
Objects holding unmanaged resources (and, I'd suggest, it's likely that
these ones do) should implement the IDisposable pattern and calling
their Dispose method /will/ free up those resources.

HTH,
Phill W.

I'm looking into the dispose method. I think that is my key - i just
need to figure out how where/when/what to do to use it effectively.
I'm trying now - thanks a lot
 
Make sure you know what 'SetProcessWorkingSetSize' is really doing:

The working set of an application is trimmed when its top-level window is
minimized
<URL:http://support.microsoft.com/?scid=kb;EN-US;293215>

thank you - i will try one thing, then this - i think the key i need
is the dispose method... i was trying it yesterday, but not correctly.
There are strides to take when just learning... thanks, Stu
 
Stu,

You are sure you are not reaching the end of the usable memory, at a 32Bit
computer that is 2Gb how much there is fysical installed.

Cor
 
I'm looking into the dispose method. I think that is my key - i just
need to figure out how where/when/what to do to use it effectively.
I'm trying now - thanks a lot

If the objects are COM/ActiveX objects, then you will need to use
ReleaseCOMObject in the Marshal class.

Chris
 
Stu,

You are sure you are not reaching the end of the usable memory, at a 32Bit
computer that is 2Gb how much there is fysical installed.

Cor

"stuforman" <[email protected]> schreef in bericht











- Show quoted text -

I have 2 gig of memory currently installed. Soon, another 2 gig will
be installed. but- i trying to run an SSIS, clear memory, run another
SSIS, clear memory again, etc - i would think that this would use only
a small bit of memory. Am I off base?
 
If the objects are COM/ActiveX objects, then you will need to use
ReleaseCOMObject in the Marshal class.

Chris- Hide quoted text -

- Show quoted text -

i'll need to read up on the Marshal class - i'm afraid i don't know
it...
 
Back
Top