RAM of 32 Bit App on 64 Bit OS

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

RAM of 32 Bit App on 64 Bit OS

Post by AUGE_OHR »

hi

since 2012 most PC have 64 UEFI where you can´t install 32 Bit OS
now i got a "new" PC with Ryzen 4650G and it "seem" i can only use 2 GB RAM for 32 Bit Apps :o

Question : how to "test" how much RAM can be used :?:
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: RAM of 32 Bit App on 64 Bit OS

Post by AUGE_OHR »

hi,

i wrote this small Demo and wonder how to avoid "Application Internal Error" ...

Code: Select all

#IFDEF __XPP__
#ELSE
   REQUEST HB_GT_WIN_DEFAULT           // Console
#ENDIF
PROCEDURE MAIN
LOCAL i
LOCAL aString := {}
LOCAL bOldError := ERRORBLOCK( { | e | BREAK( e ) } )

   BEGIN SEQUENCE
   FOR i := 1 TO 400
      ? i
      AADD(aString, REPLICATE("A",1024*10000))
   NEXT
   END SEQUENCE
   ERRORBLOCK( bOldError )
WAIT
RETURN
it crash when reach Memory Limit ... but it does not WAIT :o

hb_out.log was create
Application Internal Error - C:\hmg.3.4.4\0\MAXRAM\MAXRAM.exe
Terminated at: 2021-03-31 06:36:17
Unrecoverable error 9006: hb_xgrab can't allocate memory
Called from REPLICATE(0)
Called from MAIN(13) in C:\hmg.3.4.4\0\MAXRAM\MAXRAM.PRG
have fun
Jimmy
User avatar
salamandra
Posts: 311
Joined: Thu Jul 31, 2008 8:33 pm
DBs Used: DBF, MySQL, SQL
Location: Brazil

Re: RAM of 32 Bit App on 64 Bit OS

Post by salamandra »

Hi Jimmy,

AUGE_OHR wrote: Wed Mar 31, 2021 4:57 am hb_out.log was create
Application Internal Error - C:\hmg.3.4.4\0\MAXRAM\MAXRAM.exe
Terminated at: 2021-03-31 06:36:17
Unrecoverable error 9006: hb_xgrab can't allocate memory
Called from REPLICATE(0)
Called from MAIN(13) in C:\hmg.3.4.4\0\MAXRAM\MAXRAM.PRG
This is not an error related to used but not discarded memory ??
This is the same error it happens with HMG IDE when working with big projects...



Best regards,


Salamandra, Brazil
There is one time in which is crucial awakening. That time is now. ( Buddha )
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: RAM of 32 Bit App on 64 Bit OS

Post by Rathinagiri »

Interesting to note.

What can be the solution? Switching to 64 bits?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: RAM of 32 Bit App on 64 Bit OS

Post by edk »

Hi, See this description: https://en.wikipedia.org/wiki/Virtual_address_space

So I tried to increase the availability of VAS and it managed to 4 GB.
When compiling, set the linker flag "-Wl,--large-address-aware", ex.:

Code: Select all

HBMK2 -ldflag="-pthread  -static-libgcc  -static-libstdc++  -static -lpthread -Wl,--large-address-aware " -mt -o"%~n1" %HMGPATH%\hmg32.hbc %gtdrivers% %debug% -q %1 %2 %3 %4 %5 %6 %7 %8 >hbmk.log 2>&1
Check this code with 2GB and 4GB of VAS

Code: Select all

#IFDEF __XPP__
#ELSE
   REQUEST HB_GT_WIN_DEFAULT           // Console
#ENDIF

#define HB_MemoryLoad           1   /* approximate percentage of physical memory that is in use (0 indicates no memory use and 100 indicates full memory use) */
#define HB_TotalPhys            2   /* amount of actual physical memory, in bytes */
#define HB_AvailPhys            3   /* amount of physical memory currently available, in bytes */
#define HB_TotalPageFile        4   /* current committed memory limit for the system or the current process, whichever is smaller, in bytes */
#define HB_AvailPageFile        5   /* maximum amount of memory the current process can commit, in bytes */
#define HB_TotalVirtual         6   /* size of the user-mode portion of the virtual address space of the calling process, in bytes */
#define HB_AvailVirtual         7   /* amount of unreserved and uncommitted memory currently in the user-mode portion of the virtual address space of the calling process, in bytes */

PROCEDURE MAIN
LOCAL i
LOCAL aString := {}
LOCAL bOldError := ERRORBLOCK( { | e | BREAK( e ) } )

   BEGIN SEQUENCE
   FOR i := 1 TO 400
      ? i
      AADD(aString, REPLICATE("A",10 * ( 1024 ^ 2 )))		//10MB

      ?? ' Total VAS (MB): ' + AllTrim ( Str( INT( (GlobalMemoryStatusEx () [ HB_TotalVirtual ] / 1024^2) ) ) )
      ?? ',   Available VAS (MB): ' + Str( INT( (GlobalMemoryStatusEx () [ HB_AvailVirtual ] / 1024^2) ) )

      IF INT( (GlobalMemoryStatusEx () [ HB_AvailVirtual ] / 1024^2) ) < 50 		// Available less than 50 MB
	?? "  !!! CRITICAL !!!"
      ENDIF

      IF INT( (GlobalMemoryStatusEx () [ HB_AvailVirtual ] / 1024^2) ) < 100 		// Available less than 100 MB
	inkey(1)
      ENDIF


   NEXT i
   END SEQUENCE
   ERRORBLOCK( bOldError )
WAIT
RETURN
memo_test.7z
(560.36 KiB) Downloaded 73 times
Note that the available Virtual Address Space (VAS) has nothing to do with available of RAM.
Below is an example of a virtual machine with 192 MB of RAM, and harbour app will support 2 GB of VAS.
VAS.png
VAS.png (142.11 KiB) Viewed 823 times
Post Reply