WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Detect Free RAM?
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
Joel
Debian user
(Forum King)

Registered: Jan 2003
From: an Igloo

Question Detect Free RAM?

How can we detect free RAM in the end-user machine?

__________________

* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM
* Kubuntu 9.10 with kernel 2.6.31-14-generic.
* lighttpd, php5, perl, eruby, python.
* geany, HTML & CSS & JavaScript, mono, gtk+, QT4, wxWidgets, bash, openjdk.
* Next to use: Debian 6.0 or Ubuntu 10.04.

Quick Link | Report this post to a moderator | IP: Logged

Joel is offline Old Post 02-16-2003 04:11 PM
Click Here to See the Profile for Joel Click here to Send Joel a Private Message Click Here to Email Joel Visit Joel's homepage! Find more posts by Joel Add Joel to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

System does it again

PHP:

System
::Alloc 32
Pop
$1
System
::Call "Kernel32::GlobalMemoryStatus(i) v (r1)"
System::Call "*$1(&i4 .r2, &i4 .r3, &i4 .r4,
  &i4 .r5, &i4 .r6, &i4.r7, &i4 .r8, &i4 .r9)"
System::Free $1
DetailPrint
"Structure size (useless): $2 Bytes"
DetailPrint "Memory load: $3%"
DetailPrint "Total physical memory: $4 Bytes"
DetailPrint "Free physical memory: $5 Bytes"
DetailPrint "Total page file: $6 Bytes"
DetailPrint "Free page file: $7 Bytes"
DetailPrint "Total virtual: $8 Bytes"
DetailPrint "Free virtual: $9 Bytes"

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 02-16-2003 05:49 PM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
Joel
Debian user
(Forum King)

Registered: Jan 2003
From: an Igloo

Talking wao

thanks !!!!

didn´t know that trick

__________________

* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM
* Kubuntu 9.10 with kernel 2.6.31-14-generic.
* lighttpd, php5, perl, eruby, python.
* geany, HTML & CSS & JavaScript, mono, gtk+, QT4, wxWidgets, bash, openjdk.
* Next to use: Debian 6.0 or Ubuntu 10.04.

Quick Link | Report this post to a moderator | IP: Logged

Joel is offline Old Post 02-16-2003 05:55 PM
Click Here to See the Profile for Joel Click here to Send Joel a Private Message Click Here to Email Joel Visit Joel's homepage! Find more posts by Joel Add Joel to your buddy list Edit/Delete Message Reply w/Quote
liquidmotion
Smokes Two Joints
Beta Team

Registered: Feb 2001
From: SFBA

in mirc, just type /stat

oh wait, you need moo.dll :P

__________________
For a good time: shup | stashbox | my homepage

Quick Link | Report this post to a moderator | IP: Logged

liquidmotion is offline Old Post 02-16-2003 07:26 PM
Click Here to See the Profile for liquidmotion Click here to Send liquidmotion a Private Message Visit liquidmotion's homepage! Find more posts by liquidmotion Add liquidmotion to your buddy list Edit/Delete Message Reply w/Quote
Joel
Debian user
(Forum King)

Registered: Jan 2003
From: an Igloo

Ok, try everything..... but how can we convert to MB in Nsis,
because the $4 return in Bytes ?

__________________

* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM
* Kubuntu 9.10 with kernel 2.6.31-14-generic.
* lighttpd, php5, perl, eruby, python.
* geany, HTML & CSS & JavaScript, mono, gtk+, QT4, wxWidgets, bash, openjdk.
* Next to use: Debian 6.0 or Ubuntu 10.04.

Quick Link | Report this post to a moderator | IP: Logged

Joel is offline Old Post 02-17-2003 01:07 AM
Click Here to See the Profile for Joel Click here to Send Joel a Private Message Click Here to Email Joel Visit Joel's homepage! Find more posts by Joel Add Joel to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

This one for example:
http://nsis.sourceforge.net/archive...e.php?pageid=78

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 02-17-2003 01:23 PM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
Joel
Debian user
(Forum King)

Registered: Jan 2003
From: an Igloo

jejeje...yeah...IntOp... does it !!!!

Thanks

__________________

* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM
* Kubuntu 9.10 with kernel 2.6.31-14-generic.
* lighttpd, php5, perl, eruby, python.
* geany, HTML & CSS & JavaScript, mono, gtk+, QT4, wxWidgets, bash, openjdk.
* Next to use: Debian 6.0 or Ubuntu 10.04.

Quick Link | Report this post to a moderator | IP: Logged

Joel is offline Old Post 02-17-2003 09:14 PM
Click Here to See the Profile for Joel Click here to Send Joel a Private Message Click Here to Email Joel Visit Joel's homepage! Find more posts by Joel Add Joel to your buddy list Edit/Delete Message Reply w/Quote
spanky
Senior Member

Registered: May 2000
From:

I love system.dll.

__________________
all work and no play makes jack a dull boy

Quick Link | Report this post to a moderator | IP: Logged

spanky is offline Old Post 02-18-2003 04:50 AM
Click Here to See the Profile for spanky Click here to Send spanky a Private Message Find more posts by spanky Add spanky to your buddy list Edit/Delete Message Reply w/Quote
testtube
Junior Member

Registered: Feb 2008
From:

Old thread but I was trying to figure out how to determine how to detect the amount of system memory at install time and came across this via google.

This was very useful and got me on the right track. Most of our install targets are 64 bit systems so I needed a solution that could handle this (not 32 bit integer limited) and found I needed to use URL submitted by user. instead of URL submitted by user. . One key difference is that the structure passed to GlobalMemoryStatusEx, URL submitted by user., must have the structure size set (This isn't necessary with GlobalMemoryStatus and URL submitted by user.. If anyone's interested here's the code I used:

code:
## allocate System::Alloc 64 Pop $0 ## set # GlobalMemoryStatusEx requires structure size to set in # MEMORYSTATUSEX instance passed in as argument System::Call "*$0(i 64, i 0, l 0, l 0, l 0, l 0, l 0, l 0, l 0)" ## call System::Call "Kernel32::GlobalMemoryStatusEx(i r0)" ## get System::Call "*$0(i.r1, i.r2, l.r3, l.r4, l.r5, l.r6, l.r7, l.r8, l.r9)" ## free System::Free $0 ## print DetailPrint "Structure size: $1 bytes" DetailPrint "Memory load: $2%" DetailPrint "Total physical memory: $3 bytes" DetailPrint "Free physical memory: $4 bytes" DetailPrint "Total page file: $5 bytes" DetailPrint "Free page file: $6 bytes" DetailPrint "Total virtual: $7 bytes" DetailPrint "Free virtual: $8 bytes" DetailPrint "Free extended virtual: $9 bytes"


I thought this might save someone some time.

I apologize it it's poor etiquette to dredge up old threads. Every forum seems to have different rules...

edit:
The URLs posted above were function and structure names with links to Microsoft's MSDN docs. Right now all I see is "URL submitted by user" Sorry if this makes the post unreadable..

Last edited by testtube on 02-06-2008 at 08:32 AM

Quick Link | Report this post to a moderator | IP: Logged

testtube is offline Old Post 02-06-2008 08:01 AM
Click Here to See the Profile for testtube Click here to Send testtube a Private Message Click Here to Email testtube Find more posts by testtube Add testtube to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

You should add this code to the Wiki page:
http://nsis.sourceforge.net/Determi...e_System_plugin

And here are the links again so everyone can read them.

First link to GlobalMemoryStatusEx:
http://msdn2.microsoft.com/en-us/library/aa366589(VS.85).aspx

Second link to GlobalMemoryStatus:
http://msdn2.microsoft.com/en-us/library/aa366586(VS.85).aspx

Third link to MEMORYSTATUSEX:
http://msdn2.microsoft.com/en-us/library/aa366770(VS.85).aspx

Fourth link to MEMORYSTATUS:
http://msdn2.microsoft.com/en-us/library/aa366772(VS.85).aspx

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 02-06-2008 07:38 PM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
testtube
Junior Member

Registered: Feb 2008
From:

Just a heads up...

If you are going to manipulate values returned from the output of GlobalMemoryStatusEX use Math::Script instead of IntOp. IntOp functionality appears to be limited to signed 4 byte integers...

Quick Link | Report this post to a moderator | IP: Logged

testtube is offline Old Post 02-07-2008 11:08 PM
Click Here to See the Profile for testtube Click here to Send testtube a Private Message Click Here to Email testtube Find more posts by testtube Add testtube to your buddy list Edit/Delete Message Reply w/Quote
Anders
Major Dude

Registered: Jun 2002
From: N/A

the system plugin has Int64Op

__________________
IntOp $PostCount $PostCount + 1

Quick Link | Report this post to a moderator | IP: Logged

Anders is offline Old Post 02-07-2008 11:42 PM
Click Here to See the Profile for Anders Click here to Send Anders a Private Message Visit Anders's homepage! Find more posts by Anders Add Anders to your buddy list Edit/Delete Message Reply w/Quote
testtube
Junior Member

Registered: Feb 2008
From:

quote:
the system plugin has Int64Op


Excellent! Math::Script seemed a little too heavy weight for my needs...

Also, you may want to change your sig to Int64Op $PostCount $PostCount + 1 as your post count reaches 2^(32-1)

Quick Link | Report this post to a moderator | IP: Logged

testtube is offline Old Post 02-07-2008 11:54 PM
Click Here to See the Profile for testtube Click here to Send testtube a Private Message Click Here to Email testtube Find more posts by testtube Add testtube to your buddy list Edit/Delete Message Reply w/Quote
qwerty53
Junior Member

Registered: Feb 2008
From:

How do I make it work on 64bit ? (returns negative numbers)

on 64bit The following code

PHP:

System
::Alloc 32
  Pop
$1
  System
::Call "Kernel32::GlobalMemoryStatus(i) v (r1)"
  
System::Call "*$1(&i4 .r2, &i4 .r3, &i4 .r4, &i4 .r5,
                    &i4 .r6, &i4.r7, &i4 .r8, &i4 .r9)"
  
System::Free $1
  
  
; $5 => Free RAM
  
; $4 => Total RAM
  IntOp $R5
$5 / 1048576 ; 1048576 = 1024*1024, or MegaX
  IntOp $R4
$4 / 1048576 ; 1048576 = 1024*1024, or MegaX
  MessageBox MB_OK
"R5: $R5   5: $5   R4: $R4   4: $4"



gives this (also picture attached):
R5: -813 5: -852815872 R4: -256 4: -269082624

the real total memory is: 3.75GB of RAM

How do I make this work for a 64 bit system?
if pissible hoe to make one coade to work for both 64bit and 32bit?

Thanks!

Attachment: untitled.bmp
This has been downloaded 121 time(s).

Quick Link | Report this post to a moderator | IP: Logged

qwerty53 is offline Old Post 02-11-2008 07:45 PM
Click Here to See the Profile for qwerty53 Click here to Send qwerty53 a Private Message Click Here to Email qwerty53 Find more posts by qwerty53 Add qwerty53 to your buddy list Edit/Delete Message Reply w/Quote
testtube
Junior Member

Registered: Feb 2008
From:

Have you read the entire thread? I would guess "no"...

Quick Link | Report this post to a moderator | IP: Logged

testtube is offline Old Post 02-12-2008 04:04 AM
Click Here to See the Profile for testtube Click here to Send testtube a Private Message Click Here to Email testtube Find more posts by testtube Add testtube to your buddy list Edit/Delete Message Reply w/Quote
qwerty53
Junior Member

Registered: Feb 2008
From:

Get negative crap

Hi,
Sorry for not reading the thread :-).
So after this code:

PHP:

System
::Alloc 64
  Pop
$0
  
## set
  # GlobalMemoryStatusEx requires structure size to set in
  # MEMORYSTATUSEX instance passed in as argument
  
System::Call "*$0(i 64, i 0, l 0, l 0, l 0, l 0, l 0, l 0, l 0)"
  
## call
  
System::Call "Kernel32::GlobalMemoryStatusEx(i r0)"
  
## get
  
System::Call "*$0(i.r1, i.r2, l.r3, l.r4, l.r5, l.r6, l.r7, l.r8, l.r9)"
  
## free
  
System::Free $0
  
  MessageBox MB_OK
"TotalRAM: $3  FreeRAM: $4"
  
IntOp $vTotalRAMtemp $3 * 1
  IntOp $vTotalRAM $vTotalRAMtemp
/ 1
  
  
  MessageBox MB_OK
"TotalRAM: $vTotalRAM"
  
; $4 => Free RAM
  
; $3 => Total RAM
  
  IntOp $vTotalRAM
$3 / 1048576 ; 1048576 = 1024*1024, or MegaX
  IntOp $vFreeRAM
$4 / 1048576 ; 1048576 = 1024*1024, or MegaX
  MessageBox MB_OK
"vTotalRAM: $vTotalRAM"



on a 64 bit machine I get: -262776
if I printout the $3 it gives the right value in bytes: 4025884672.
in fact I get negative number even if I do $3 +1

thanks

Quick Link | Report this post to a moderator | IP: Logged

qwerty53 is offline Old Post 02-12-2008 05:22 PM
Click Here to See the Profile for qwerty53 Click here to Send qwerty53 a Private Message Click Here to Email qwerty53 Find more posts by qwerty53 Add qwerty53 to your buddy list Edit/Delete Message Reply w/Quote
testtube
Junior Member

Registered: Feb 2008
From:

In posts subsequent to the GlobalMemoryStatusEX post you'll find that you need to use System::Int64Op to do 64 bit math.

My code looks like:

code:
System::Alloc 64 Pop $0 System::Call "*$0(i 64)" System::Call "Kernel32::GlobalMemoryStatusEx(i r0)" System::Call "*$0(i, i, l.r1, l, l, l, l, l, l)" System::Free $0 ; convert bytes to megabytes System::Int64Op $1 / 1048576 Pop $1

Quick Link | Report this post to a moderator | IP: Logged

testtube is offline Old Post 02-12-2008 05:58 PM
Click Here to See the Profile for testtube Click here to Send testtube a Private Message Click Here to Email testtube Find more posts by testtube Add testtube to your buddy list Edit/Delete Message Reply w/Quote
qwerty53
Junior Member

Registered: Feb 2008
From:

THANKS ALOT!!!!!!!!!!!!

THANKS ALOT!!!!!!!!!!!!

Quick Link | Report this post to a moderator | IP: Logged

qwerty53 is offline Old Post 02-12-2008 08:05 PM
Click Here to See the Profile for qwerty53 Click here to Send qwerty53 a Private Message Click Here to Email qwerty53 Find more posts by qwerty53 Add qwerty53 to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 10:02 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Detect Free RAM?
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON