QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Petr on October 18, 2021, 03:58:01 pm

Title: How to find free memory?
Post by: Petr 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?
Title: Re: How to find free memory?
Post by: SMcNeill on October 18, 2021, 04:39:21 pm
https://www.qb64.org/forum/index.php?topic=2694.msg118969#msg118969

Are these routine what you're looking for?
Title: Re: How to find free memory?
Post by: Petr 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!
Title: Re: How to find free memory?
Post by: Petr 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.
Title: Re: How to find free memory?
Post by: SMcNeill on October 18, 2021, 05:06:32 pm
Glad they’re what you're looking for.  👍
Title: Re: How to find free memory?
Post by: Petr on October 18, 2021, 05:15:03 pm
This is my status now:

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: How to find free memory?
Post by: Pete 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!
Title: Re: How to find free memory?
Post by: Petr 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.
Title: Re: How to find free memory?
Post by: SpriggsySpriggs 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
Title: Re: How to find free memory?
Post by: Richard 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.  
Title: Re: How to find free memory?
Post by: FellippeHeitor 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.
🙊🙈🙉