Author Topic: How to find free memory?  (Read 4209 times)

0 Members and 1 Guest are viewing this topic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
How to find free memory?
« on: October 18, 2021, 03:58:01 pm »
Hi. Do you already know what happens if you exceed the available free memory? The MEM field reports that the memory has been freed. I was now opening an MP3 file with a length of 1 hour and 33 minutes, and I had about 40 songs with a length of about 3 minutes each loaded in my memory. The great news is that it ended in an error message, so you know what to look for. That's absolutely perfect. Yeah, I'm testing my program with really brutal methods, because I don't want to be ashamed of it. So. Is there any direct function in QB64, please?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: How to find free memory?
« Reply #1 on: October 18, 2021, 04:39:21 pm »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: How to find free memory?
« Reply #2 on: October 18, 2021, 04:45:51 pm »
I forgot! Thank you very much! I'll look into it immediately! Thanks wery much! Perfect, absolutly perfect!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: How to find free memory?
« Reply #3 on: October 18, 2021, 04:58:20 pm »
Yes! I've tried it, it's clear, understandable, that's exactly what I need. I'll use it in my program, which is still running in the background, the fan on the processor is roaring, but the speakers will overroaring it, just a complete idyll according to my taste!

Thank you again, Steven.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: How to find free memory?
« Reply #4 on: October 18, 2021, 05:06:32 pm »
Glad they’re what you're looking for.  👍
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: How to find free memory?
« Reply #5 on: October 18, 2021, 05:15:03 pm »
This is my status now:

  [ You are not allowed to view this attachment ]  

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: How to find free memory?
« Reply #6 on: October 18, 2021, 05:21:28 pm »
I like Steve's Library. I rate it 5 out of 5: 🎃🎃🎃🎃🎃

That's right, I learned where the emojis were hiding. Wooohahahahah!
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: How to find free memory?
« Reply #7 on: October 18, 2021, 05:26:58 pm »
Want to see how I solved the problem in my program? I offer stable source code. If you are interested, I will publish it (in the same functionality as in thread about convertoffset but stable). Definitely tomorrow (I have 23:25) I will continue hard, because I finally have a stable engine. I'm literally excited. I am very happy. I have a lot of ideas about what to add to the program and I know how to do it. Now there is nothing to stop it. Amazing. It's just absolutely amazing.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: How to find free memory?
« Reply #8 on: October 18, 2021, 07:42:51 pm »
You don't actually need Steve's header files to do this. It can be done entirely within QB64. I have code for this somewhere
Shuwatch!

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: How to find free memory?
« Reply #9 on: October 18, 2021, 08:46:51 pm »
@Petr

try this

Code: QB64: [Select]
  1. DIM SHARED memstat AS MEMORYSTATUSEX
  2. TYPE MEMORYSTATUSEX
  3.     dwLength AS LONG
  4.     dwMemoryLoad AS LONG
  5.     ullTotalPhys AS _UNSIGNED _INTEGER64
  6.     ullAvailPhys AS _UNSIGNED _INTEGER64
  7.     ullTotalPageFile AS _UNSIGNED _INTEGER64
  8.     ullAvailPageFile AS _UNSIGNED _INTEGER64
  9.     ullTotalVirtual AS _UNSIGNED _INTEGER64
  10.     ullAvailVirtual AS _UNSIGNED _INTEGER64
  11.     ullAvailExtendedVirtual AS _UNSIGNED _INTEGER64
  12. DECLARE CUSTOMTYPE LIBRARY 'Memory Information using KERNEL32
  13.     FUNCTION GlobalMemoryStatusEx& (Mstat AS MEMORYSTATUSEX)
  14.  
  15. gosub Free_MEM:
  16.  
  17. Free_MEM:
  18. memstat.dwLength = LEN(memstat): Result = GlobalMemoryStatusEx&(memstat)
  19. Free_MEM&= memstat.ullAvailPhys:print "freeMEM= ";:print using "###,###,###,###";memstat.ullAvailPhys;:print " bytes";
  20.  

FellippeHeitor

  • Guest
Re: How to find free memory?
« Reply #10 on: October 18, 2021, 10:26:03 pm »
I like Steve's Library. I rate it 5 out of 5: 🎃🎃🎃🎃🎃

That's right, I learned where the emojis were hiding. Wooohahahahah!

Oh, God. It starts.
🙊🙈🙉