forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Reduice Memory Useage!!
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code
View previous topic :: View next topic  
Author Message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1731
Location: Space and Time

PostPosted: Tue Nov 28, 2006 1:41 pm    Post subject: Reduice Memory Useage!! Reply with quote

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://vdsfreak.com


Last edited by LiquidCode on Tue Nov 28, 2006 9:29 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Tue Nov 28, 2006 3:20 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 179
Location: FRANCE

PostPosted: Tue Nov 28, 2006 10:08 pm    Post subject: Reply with quote

Very very very very... very Good !!!!!! Shocked
25Mo -> ~1Mo...


Last edited by GregLand on Sun Nov 25, 2007 5:30 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1731
Location: Space and Time

PostPosted: Tue Nov 28, 2006 11:37 pm    Post subject: Reply with quote

Yeah, I like it. Smile

I have only used it on Windows XP. Can someone check if it works on 98,NT, 2K and Vista?

Thanks

_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 179
Location: FRANCE

PostPosted: Tue Nov 28, 2006 11:52 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1731
Location: Space and Time

PostPosted: Tue Nov 28, 2006 11:56 pm    Post subject: Reply with quote

Sweet. Thanks
_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kc7aad
Contributor
Contributor


Joined: 09 Oct 2005
Posts: 53
Location: Spokane Washington

PostPosted: Wed Nov 29, 2006 12:48 am    Post subject: Reply with quote

HOLY @#$%!!!!

What.. competeing for the title of All Mighty???!!!!!!!

Nice one!!
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Wed Nov 29, 2006 5:44 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Wed Nov 29, 2006 9:12 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Wed Nov 29, 2006 11:22 am    Post subject: Reply with quote

Impressive! So far works like a charm!

Thanks for sharing Chris! Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Nov 30, 2006 7:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 179
Location: FRANCE

PostPosted: Sun Nov 25, 2007 5:33 pm    Post subject: Reply with quote

Hello

Is there a way to Reduce Memory Usage of a non VDS app. like FireFox, Photoshop... using this script ?
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun Nov 25, 2007 8:03 pm    Post subject: Reply with quote

Here is more info about the API being used:

http://msdn2.microsoft.com/en-us/library/ms682606.aspx

You need a handle of the process you want to apply the EmptyWorkingSet function to. I don't know if they mean the handles you can get by doing list tasklist, but it might be worth a try Smile

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 179
Location: FRANCE

PostPosted: Mon Nov 26, 2007 3:13 am    Post subject: Reply with quote

Hello Skit3000
I tried this but it do not work... Sad

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
View user's profile Send private message Visit poster's website
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Mon Nov 26, 2007 12:59 pm    Post subject: Reply with quote

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 Smile


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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group