FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour error with nExtMem()
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
error with nExtMem()
Posted: Thu Sep 01, 2011 04:57 PM
Hello.

In errsysw.prg, nExtMem() does not indicate my 6 GB of Ram.

It only says 1 megs:

Hardware memory: 1 megs



Also, it may cause internal problems to FWH, as it points out no memory, when in fact it is plenty of gbs!!.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Re: error with nExtMem()
Posted: Wed Sep 21, 2011 06:05 PM

Hello,

Is there any update?.

Thanks

FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: error with nExtMem()
Posted: Wed Sep 21, 2011 06:17 PM

John,

Please run this and let us know what you get, thanks:

MsgInfo( Int( nExtMem() / ( 1024 * 1024 * 1024 ) ) + 1 )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Re: error with nExtMem()
Posted: Wed Sep 21, 2011 06:32 PM

Antonio,

I just get 1.

Thanks.

FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: error with nExtMem()
Posted: Wed Sep 21, 2011 10:32 PM

Here we get 2 which it is right,

Could someone else test it and report the result here ? thanks :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 08:34 AM

I get 2, which is right too.

EMG

Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 08:54 AM

I get 1, wich is wrong.

Felix

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 09:46 AM

Are you using latest FWH?

EMG

Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 10:08 AM

Enrico,

yes and Harbour 3.

Felix

Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 10:11 AM

I have 8 GB of RAM, so I can´t get 1!!

FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 10:12 AM
FWH function nExtMem() is a simple wrapper to the Windows API function GlobalMemoryStatus() :

http://msdn.microsoft.com/en-us/library/aa366586(v=VS.85).aspx

that fills a struct:

http://msdn.microsoft.com/en-us/library/aa366772(v=VS.85).aspx

In that struct we check the value of dwTotalPhys that as the API explains:

The amount of actual physical memory, in bytes.


FWH code:
Code (fw): Select all Collapse
HB_FUNC( NEXTMEM ) // --> nHardwareMemory
{
   MEMORYSTATUS mst;

   mst.dwLength = sizeof( MEMORYSTATUS );

   GlobalMemoryStatus( &mst );

   hb_retnl( mst.dwTotalPhys );
}

Our code does nothing except the call to Windows API, so the question is; is that WIndows API function failing ? :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 103
Joined: Sat Oct 18, 2008 08:13 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 10:20 AM
Hi Antonio,

Antonio Linares wrote:FWH function nExtMem() is a simple wrapper to the Windows API function GlobalMemoryStatus() :
Our code does nothing except to call to Windows API, so the question is; is that WIndows API function failing ? :-)


Have a look here: http://msdn.microsoft.com/en-us/library/aa366586.aspx:

On computers with more than 4 GB of memory, the GlobalMemoryStatus function can return incorrect information, reporting a value of –1 to indicate an overflow. For this reason, applications should use the GlobalMemoryStatusEx function instead.
Best Regards,

Ruediger Alich



---

HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 10:30 AM
Ruediger,

Thanks for the info, I wasn't aware of this API function. So this is the new code to test:

Code (fw): Select all Collapse
HB_FUNC( NEXTMEM ) // --> nHardwareMemory
{
   MEMORYSTATUSEX mst;

   mst.dwLength = sizeof( MEMORYSTATUSEX );

   GlobalMemoryStatusEx( &mst );

   hb_retnl( mst.ullAvailPhys );
}

we could also try:

   hb_retnll( mst.ullAvailPhys );
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 10:55 AM
The correct is:

Code (fw): Select all Collapse
hb_retnll( mst.ullTotalPhys );



I got 8.

So I hope MsgInfo( Int( nExtMem() / ( 1024 * 1024 * 1024 ) ) + 1 ) refers to 8 GB.

Is it correct?.

Thanks,.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: error with nExtMem()
Posted: Thu Sep 22, 2011 11:14 AM

Yes, it seems so :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com