Home All Groups Group Topic Archive Search About
Author
28 Feb 2006 1:19 PM
Adrian
Hi
    From within a VB app how do you cause a global memory compaction or free
up as per the many memory freeing applications?

Can you say via VB to windows to clean-up/ free up memory used by just one
application?

I have been looking for an example but thus far can't find one!


Thanks

Author
28 Feb 2006 1:24 PM
Carlos J. Quintero [VB MVP]
Hi Adrian,

If you are referring to VB.NET (and not VB6), the memory is automatically
managed and you don´t have to worry about that, the operating system signals
applications when the system is low on memory and .NET applications free
memory. You can force it on your .NET application calling
System.GC.Collect().

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com


Show quoteHide quote
"Adrian" <Adrian@nospamhotmail.com.uk> escribió en el mensaje
news:du1il3$mjh$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
> Hi
>    From within a VB app how do you cause a global memory compaction or
> free up as per the many memory freeing applications?
>
> Can you say via VB to windows to clean-up/ free up memory used by just one
> application?
>
> I have been looking for an example but thus far can't find one!
>
>
> Thanks
>
Author
28 Feb 2006 1:36 PM
Adrian
Thanks the app is dotnet But the memory clean up is not for this app its for
an older app! I was hoping to write a simple clean up app that would cause
either a garbage collection for the one app or system wide which I would
trigger from my VB.Net app.

System.GC.Collect() is this system wide or just for dotnet apps?

Thanks

Show quoteHide quote
"Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> wrote in message
news:%23IbBUpGPGHA.344@TK2MSFTNGP11.phx.gbl...
> Hi Adrian,
>
> If you are referring to VB.NET (and not VB6), the memory is automatically
> managed and you don´t have to worry about that, the operating system
> signals applications when the system is low on memory and .NET
> applications free memory. You can force it on your .NET application
> calling System.GC.Collect().
>
> --
>
> Best regards,
>
> Carlos J. Quintero
>
> MZ-Tools: Productivity add-ins for Visual Studio
> You can code, design and document much faster:
> http://www.mztools.com
>
>
> "Adrian" <Adrian@nospamhotmail.com.uk> escribió en el mensaje
> news:du1il3$mjh$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
>> Hi
>>    From within a VB app how do you cause a global memory compaction or
>> free up as per the many memory freeing applications?
>>
>> Can you say via VB to windows to clean-up/ free up memory used by just
>> one application?
>>
>> I have been looking for an example but thus far can't find one!
>>
>>
>> Thanks
>>
>
>
Author
28 Feb 2006 2:24 PM
Carlos J. Quintero [VB MVP]
System.GC.Collect only affects to your own .NET app.

For your purpose, see the WM_COMPACTING Win32 message:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmessages/wm_compacting.asp
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com


Show quoteHide quote
"Adrian" <Adrian@nospamhotmail.com.uk> escribió en el mensaje
news:du1jk5$oq2$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
> Thanks the app is dotnet But the memory clean up is not for this app its
> for an older app! I was hoping to write a simple clean up app that would
> cause either a garbage collection for the one app or system wide which I
> would trigger from my VB.Net app.
>
> System.GC.Collect() is this system wide or just for dotnet apps?
>
> Thanks
>
> "Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> wrote in
> message news:%23IbBUpGPGHA.344@TK2MSFTNGP11.phx.gbl...
>> Hi Adrian,
>>
>> If you are referring to VB.NET (and not VB6), the memory is automatically
>> managed and you don´t have to worry about that, the operating system
>> signals applications when the system is low on memory and .NET
>> applications free memory. You can force it on your .NET application
>> calling System.GC.Collect().
>>
>> --
>>
>> Best regards,
>>
>> Carlos J. Quintero
>>
>> MZ-Tools: Productivity add-ins for Visual Studio
>> You can code, design and document much faster:
>> http://www.mztools.com
>>
>>
>> "Adrian" <Adrian@nospamhotmail.com.uk> escribió en el mensaje
>> news:du1il3$mjh$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
>>> Hi
>>>    From within a VB app how do you cause a global memory compaction or
>>> free up as per the many memory freeing applications?
>>>
>>> Can you say via VB to windows to clean-up/ free up memory used by just
>>> one application?
>>>
>>> I have been looking for an example but thus far can't find one!
>>>
>>>
>>> Thanks
>>>
>>
>>
>
>
Author
28 Feb 2006 4:01 PM
Adrian
Thanks Carlos
                How do you send such messages fom VB.net?


Show quoteHide quote
"Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> wrote in message
news:ejCFCLHPGHA.2012@TK2MSFTNGP14.phx.gbl...
> System.GC.Collect only affects to your own .NET app.
>
> For your purpose, see the WM_COMPACTING Win32 message:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmessages/wm_compacting.asp
> --
>
> Best regards,
>
> Carlos J. Quintero
>
> MZ-Tools: Productivity add-ins for Visual Studio
> You can code, design and document much faster:
> http://www.mztools.com
>
>
> "Adrian" <Adrian@nospamhotmail.com.uk> escribió en el mensaje
> news:du1jk5$oq2$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
>> Thanks the app is dotnet But the memory clean up is not for this app its
>> for an older app! I was hoping to write a simple clean up app that would
>> cause either a garbage collection for the one app or system wide which I
>> would trigger from my VB.Net app.
>>
>> System.GC.Collect() is this system wide or just for dotnet apps?
>>
>> Thanks
>>
>> "Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> wrote in
>> message news:%23IbBUpGPGHA.344@TK2MSFTNGP11.phx.gbl...
>>> Hi Adrian,
>>>
>>> If you are referring to VB.NET (and not VB6), the memory is
>>> automatically managed and you don´t have to worry about that, the
>>> operating system signals applications when the system is low on memory
>>> and .NET applications free memory. You can force it on your .NET
>>> application calling System.GC.Collect().
>>>
>>> --
>>>
>>> Best regards,
>>>
>>> Carlos J. Quintero
>>>
>>> MZ-Tools: Productivity add-ins for Visual Studio
>>> You can code, design and document much faster:
>>> http://www.mztools.com
>>>
>>>
>>> "Adrian" <Adrian@nospamhotmail.com.uk> escribió en el mensaje
>>> news:du1il3$mjh$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
>>>> Hi
>>>>    From within a VB app how do you cause a global memory compaction or
>>>> free up as per the many memory freeing applications?
>>>>
>>>> Can you say via VB to windows to clean-up/ free up memory used by just
>>>> one application?
>>>>
>>>> I have been looking for an example but thus far can't find one!
>>>>
>>>>
>>>> Thanks
>>>>
>>>
>>>
>>
>>
>
>
Author
28 Feb 2006 5:43 PM
Adrian
ok done this:

Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd
As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long)
As Long

Sub Main()
Dim myresult As Long
myresult = PostMessage(-1, 65, 0, 0)
MsgBox(myresult.ToString)
End Sub

but it still does not free the memory used by the old app applications such
as MEMORyAL 4.2.1
do, how do they do it?


Show quoteHide quote
"Adrian" <Adrian@nospamhotmail.com.uk> wrote in message
news:du1s56$ebi$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
> Thanks Carlos
>                How do you send such messages fom VB.net?
>
>
> "Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> wrote in
> message news:ejCFCLHPGHA.2012@TK2MSFTNGP14.phx.gbl...
>> System.GC.Collect only affects to your own .NET app.
>>
>> For your purpose, see the WM_COMPACTING Win32 message:
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmessages/wm_compacting.asp
>> --
>>
>> Best regards,
>>
>> Carlos J. Quintero
>>
>> MZ-Tools: Productivity add-ins for Visual Studio
>> You can code, design and document much faster:
>> http://www.mztools.com
>>
>>
>> "Adrian" <Adrian@nospamhotmail.com.uk> escribió en el mensaje
>> news:du1jk5$oq2$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
>>> Thanks the app is dotnet But the memory clean up is not for this app its
>>> for an older app! I was hoping to write a simple clean up app that would
>>> cause either a garbage collection for the one app or system wide which I
>>> would trigger from my VB.Net app.
>>>
>>> System.GC.Collect() is this system wide or just for dotnet apps?
>>>
>>> Thanks
>>>
>>> "Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> wrote in
>>> message news:%23IbBUpGPGHA.344@TK2MSFTNGP11.phx.gbl...
>>>> Hi Adrian,
>>>>
>>>> If you are referring to VB.NET (and not VB6), the memory is
>>>> automatically managed and you don´t have to worry about that, the
>>>> operating system signals applications when the system is low on memory
>>>> and .NET applications free memory. You can force it on your .NET
>>>> application calling System.GC.Collect().
>>>>
>>>> --
>>>>
>>>> Best regards,
>>>>
>>>> Carlos J. Quintero
>>>>
>>>> MZ-Tools: Productivity add-ins for Visual Studio
>>>> You can code, design and document much faster:
>>>> http://www.mztools.com
>>>>
>>>>
>>>> "Adrian" <Adrian@nospamhotmail.com.uk> escribió en el mensaje
>>>> news:du1il3$mjh$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
>>>>> Hi
>>>>>    From within a VB app how do you cause a global memory compaction or
>>>>> free up as per the many memory freeing applications?
>>>>>
>>>>> Can you say via VB to windows to clean-up/ free up memory used by just
>>>>> one application?
>>>>>
>>>>> I have been looking for an example but thus far can't find one!
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
3 Mar 2006 9:48 AM
Armin Zingler
"Adrian" <Adrian@nospamhotmail.com.uk> schrieb
> ok done this:
>
> Declare Function PostMessage Lib "user32" Alias "PostMessageA"
> (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer,
> ByVal lParam As Long) As Long


This declaration is for VB6.


VB.Net declaration:

Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
   (ByVal hwnd As IntPtr, ByVal wMsg As Integer, _
   ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean


I only corrected the declaration. I don't know if this solves the problem.

(see also System.Windows.Forms.Message)


Armin