View previous topic :: View next topic |
Author |
Message |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Tue Nov 28, 2006 1:41 pm Post subject: Reduice Memory Useage!! |
|
|
I love VDS 5!! Here is a small bit of code that will reduce the memory useage of your application. You can put it in your event loop or at key spots in your script. I have tested it with no ill effects.
Code: |
loadlib "psapi.dll"
%t = @lib("psapi.dll","EmptyWorkingSet",INT:,-1)
freelib "psapi.dll"
|
_________________ Chris
Http://theblindhouse.com
Last edited by LiquidCode on Tue Nov 28, 2006 9:29 pm; edited 2 times in total |
|
Back to top |
|
|
DaveR Valued Contributor
Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Tue Nov 28, 2006 3:20 pm Post subject: |
|
|
Wow! My VDS tray applications usually use between 7,000 and 8,000 K. I just added your code to the event loop of one and the memory used dropped from 7,350K to ~700K - with occasional spikes to 2,000K.
Thanks LC _________________ cheers
Dave |
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Tue Nov 28, 2006 10:08 pm Post subject: |
|
|
Very very very very... very Good !!!!!!
25Mo -> ~1Mo...
Last edited by GregLand on Sun Nov 25, 2007 5:30 pm; edited 1 time in total |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Tue Nov 28, 2006 11:37 pm Post subject: |
|
|
Yeah, I like it.
I have only used it on Windows XP. Can someone check if it works on 98,NT, 2K and Vista?
Thanks _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Tue Nov 28, 2006 11:52 pm Post subject: |
|
|
Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Ref.
Last edited by GregLand on Sun Nov 25, 2007 6:58 pm; edited 2 times in total |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
|
Back to top |
|
|
kc7aad Contributor
Joined: 09 Oct 2005 Posts: 53 Location: Spokane Washington
|
Posted: Wed Nov 29, 2006 12:48 am Post subject: |
|
|
HOLY @#$%!!!!
What.. competeing for the title of All Mighty???!!!!!!!
Nice one!!
Thanks |
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Nov 29, 2006 5:44 am Post subject: |
|
|
Keep in mind that this will slow your app down if it uses/checks variables very often, as they are constantly put in and taken out of memory.
Very good idea for system tray/background apps though. _________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Wed Nov 29, 2006 9:12 am Post subject: |
|
|
This is a very useful post. However, alarm bells rang over the availability of it. The VDS runtime uses it to get the task list and processes under Windows NT and greater only, and it loads it only when required and caters for the possibility that it is not available. So my feeling is that its availability should not be taken for granted.
As far as I know psaspi.dll is NOT available on Win9x, nor on Windows NT, though a redistributable version for NT is available from Microsoft. If you are going to use it, I would test for its existence at the start of the script and load it if it exists, and set a variable %%psapi_loaded = 1, and then call it only if the variable is true. That would avoid problems on systems where it doesn't exist. _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
marty Professional Member
Joined: 10 May 2001 Posts: 789
|
Posted: Wed Nov 29, 2006 11:22 am Post subject: |
|
|
Impressive! So far works like a charm!
Thanks for sharing Chris! |
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Thu Nov 30, 2006 7:16 pm Post subject: |
|
|
Hi All,
IMHO I would be carefull using this function. You are removing available memory pages from a process which could slow the performance of your program. _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Sun Nov 25, 2007 5:33 pm Post subject: |
|
|
Hello
Is there a way to Reduce Memory Usage of a non VDS app. like FireFox, Photoshop... using this script ? |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Mon Nov 26, 2007 3:13 am Post subject: |
|
|
Hello Skit3000
I tried this but it do not work...
Code: |
loadlib "psapi.dll"
%t = @lib("psapi.dll","EmptyWorkingSet",INT:,firefox.exe)
freelib "psapi.dll"
|
Have you an idea of the script ? |
|
Back to top |
|
|
ShinobiSoft Professional Member
Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Mon Nov 26, 2007 12:59 pm Post subject: |
|
|
Skit3000 wrote: | ... I don't know if they mean the handles you can get by doing list tasklist, but it might be worth a try |
The handle in question is a handle to the applications instance. You can
get an applications instance (HINSTANCE) handle with several APIs.
Gregland, replace "firefox.exe" with the value obtained from
GetModuleHandle("x:\pathtofirefox\firefox.exe"). This API resides in the
Kernel32.dll. It may be GetModuleHandleA() or GetModuleHandleW().
Call this API after the application is loaded into memory. _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
Back to top |
|
|
|