• total and free or used ram memory

    From CV@21:1/5 to All on Wed Jun 28 12:34:19 2023
    Hi all

    In an application I wrote sometime ago, I need to add this for documenting purposes:

    - the total amount of ram memory installed (for example 8 gb or 8192 mb or whatever)
    AND
    (the total _free_ ram memory available OR the total _used_ ram memory)

    I don't need the amount of memory used by the application - I can play with the memory(...) function for that.
    Something like the windows task manager shows when invoked - no matter the windows version (and by now, no need to know all the details task manager shows, i.e. the applications-running list).

    Is there a way to get this under xharbour?
    Preferably by code, not invoking a command line utility.

    Best regards
    --
    Claudio Voskian
    Buenos Aires - Argentina

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From CV@21:1/5 to All on Wed Jun 28 13:10:43 2023
    El miércoles, 28 de junio de 2023 a la(s) 16:34:21 UTC-3, CV escribió:
    Hi all

    In an application I wrote sometime ago, I need to add this for documenting purposes:

    - the total amount of ram memory installed (for example 8 gb or 8192 mb or whatever)
    AND
    (the total _free_ ram memory available OR the total _used_ ram memory)

    I don't need the amount of memory used by the application - I can play with the memory(...) function for that.
    Something like the windows task manager shows when invoked - no matter the windows version (and by now, no need to know all the details task manager shows, i.e. the applications-running list).

    Is there a way to get this under xharbour?
    Preferably by code, not invoking a command line utility.

    Best regards
    --
    Claudio Voskian
    Buenos Aires - Argentina

    Hi

    I just noticed that I will not find the total memory because I'm using a 32 bit application, and will not see the real total (more than 4 gb in this case, 32 gb in the client machine).

    Please, disregard my request.

    Regards
    ©

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From CV@21:1/5 to All on Fri Aug 4 12:27:08 2023
    El miércoles, 28 de junio de 2023 a la(s) 17:10:44 UTC-3, CV escribió:
    El miércoles, 28 de junio de 2023 a la(s) 16:34:21 UTC-3, CV escribió:
    Hi all

    In an application I wrote sometime ago, I need to add this for documenting purposes:

    - the total amount of ram memory installed (for example 8 gb or 8192 mb or whatever)
    AND
    (the total _free_ ram memory available OR the total _used_ ram memory)

    I don't need the amount of memory used by the application - I can play with the memory(...) function for that.
    Something like the windows task manager shows when invoked - no matter the windows version (and by now, no need to know all the details task manager shows, i.e. the applications-running list).

    Is there a way to get this under xharbour?
    Preferably by code, not invoking a command line utility.

    Best regards
    --
    Claudio Voskian
    Buenos Aires - Argentina
    Hi

    I just noticed that I will not find the total memory because I'm using a 32 bit application, and will not see the real total (more than 4 gb in this case, 32 gb in the client machine).

    Please, disregard my request.

    Regards
    ©
    Hi

    for those of you willing to know this information (about total, used and free memory installed), I write this set of functions (works fine under xharbour 32 bits):

    // bof
    function main()

    ? "total", TOTALMEMORY(), "used", USEDMEMORY(), "free", FREEMEMORY() // all in bytes

    return nil

    #pragma BEGINDUMP
    #include <windows.h>

    HB_FUNC( TOTALMEMORY ) {
    MEMORYSTATUSEX st;
    st.dwLength = sizeof(st);
    GlobalMemoryStatusEx(&st);

    hb_retnll( ( LONGLONG ) st.ullTotalPhys);
    }

    HB_FUNC( USEDMEMORY ) {
    MEMORYSTATUSEX st;
    st.dwLength = sizeof(st);
    GlobalMemoryStatusEx(&st);

    hb_retnll( ( LONGLONG ) st.ullTotalPhys - st.ullAvailPhys);
    }

    HB_FUNC( FREEMEMORY ) {
    MEMORYSTATUSEX st;
    st.dwLength = sizeof(st);
    GlobalMemoryStatusEx(&st);

    hb_retnll( ( LONGLONG ) st.ullAvailPhys);
    }
    #pragma ENDDUMP
    // eof

    Regards
    --
    Claudio Voskian
    Buenos Aires - Argentina

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From reinaldohf@gmail.com@21:1/5 to All on Fri Aug 4 16:56:35 2023
    Hi Claudio,


    // bof
    function main()

    ? "total", TOTALMEMORY(), "used", USEDMEMORY(), "free", FREEMEMORY() // all in bytes

    return nil

    #pragma BEGINDUMP
    #include <windows.h>

    HB_FUNC( TOTALMEMORY ) {
    MEMORYSTATUSEX st;
    st.dwLength = sizeof(st);
    GlobalMemoryStatusEx(&st);

    hb_retnll( ( LONGLONG ) st.ullTotalPhys);
    }

    HB_FUNC( USEDMEMORY ) {
    MEMORYSTATUSEX st;
    st.dwLength = sizeof(st);
    GlobalMemoryStatusEx(&st);

    hb_retnll( ( LONGLONG ) st.ullTotalPhys - st.ullAvailPhys);
    }

    HB_FUNC( FREEMEMORY ) {
    MEMORYSTATUSEX st;
    st.dwLength = sizeof(st);
    GlobalMemoryStatusEx(&st);

    hb_retnll( ( LONGLONG ) st.ullAvailPhys);
    }
    #pragma ENDDUMP
    // eof
    For me it works fine!
    Thanks for the code!

    Reynaldo Henrique

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)