Author Topic: Memory allocation issue in windows with QB64  (Read 4526 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Memory allocation issue in windows with QB64
« on: September 10, 2018, 08:20:15 pm »
it seems that I can only allocate approx 269megs of ram to a QB64 program using Windows. [banned user] had no trouble in Linux running this test sample.

Code: QB64: [Select]
  1. TYPE FileDatabase
  2.  NameL AS STRING * 256
  3.  Directory AS STRING * 256
  4.  Size AS SINGLE
  5.  DateStamp AS STRING * 10
  6.  TimeStamp AS STRING * 8
  7.  IS_Directory AS _BYTE
  8.  IS_File AS _BYTE
  9.  
  10. DIM SHARED FF(770000) AS FileDatabase
  11.  

but when I try it gives an Out Of Memory error if I reduce the array size down to where the 536*N<~282000000 then it works for me.(which is about ~528000) Task Manager gives nearly 2000megs free so its not an insufficient memory issue.
Any Idea why its a problem in windows, can anybody else running windows (vista or 7) try and see if they receive a memory error too? see if maybe its just my machines(does this on both desktops and both laptops running Vista and 7).
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Memory allocation issue in windows with QB64
« Reply #1 on: September 10, 2018, 08:56:58 pm »
QB64 on macOS has no issue with the code above either, so we can isolate the issue to Windows indeed.

Wonder if the folks with the 64bit compiler injected by Steve will get the same crash.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Memory allocation issue in windows with QB64
« Reply #2 on: September 10, 2018, 11:36:28 pm »
OK here

FellippeHeitor

  • Guest
Re: Memory allocation issue in windows with QB64
« Reply #3 on: September 10, 2018, 11:40:57 pm »
What system? What version of QB64? Is it Steve's mod?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Memory allocation issue in windows with QB64
« Reply #4 on: September 10, 2018, 11:49:12 pm »
What system? What version of QB64? Is it Steve's mod?

It is.  You can tell by the title being "QB64 x64" in the screenshot.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Memory allocation issue in windows with QB64
« Reply #5 on: September 10, 2018, 11:58:05 pm »
Yes 64 x 64 and this: v1.2 2018 0228/86 git b30af92

FellippeHeitor

  • Guest
Re: Memory allocation issue in windows with QB64
« Reply #6 on: September 10, 2018, 11:59:12 pm »
Oh, there's a screenshot.

I'm always in the "Recent posts" page and don't get to see attachments unless I click the post to read it.

Ok.

Offline Omerta7486

  • Newbie
  • Posts: 33
  • √𝜋²
    • View Profile
Re: Memory allocation issue in windows with QB64
« Reply #7 on: September 11, 2018, 12:08:06 am »
Well, I'm in Windows 10 with Steve's x64 newest version, and I put in 1G with no problems.
The knowledge that's seeking the favor of another means the murder of self.

Latest version of my game, here  Omertris: Invasion

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Memory allocation issue in windows with QB64
« Reply #8 on: September 11, 2018, 12:24:27 am »
Well, I'm in Windows 10 with Steve's x64 newest version, and I put in 1G with no problems.

I've got a few massive QBDbases which hold around 20GB of data...  They all load and run fine under QB64 x64.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Memory allocation issue in windows with QB64
« Reply #9 on: September 11, 2018, 12:46:14 am »
I may need a copy of that.

though its not like I'm exceeding 4gigs not even close. so 32bit should be plenty, you would think.
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Memory allocation issue in windows with QB64
« Reply #10 on: September 11, 2018, 12:49:29 am »
I may need a copy of that.

though its not like I'm exceeding 4gigs not even close. so 32bit should be plenty, you would think.

Do you use _TRIM allot?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Memory allocation issue in windows with QB64
« Reply #11 on: September 11, 2018, 01:02:05 am »
I may need a copy of that.

though its not like I'm exceeding 4gigs not even close. so 32bit should be plenty, you would think.

32-bit actually limits you to (supposedly) 2GB, though in actuality, it's closer to 1.5GB of memory in most cases, as Windows reserves a certain amount of space with each program for itself.  Just try a simple program to see when "Out of Memory" pops up for you:

DIM m AS _MEM, sz AS _INTEGER64
DO
    sz = sz + 10000000 '10 million bytes at a time
    PRINT sz
    m = _MEMNEW(sz) 'reserve a data space of proper size
    _MEMFREE m
LOOP

Run it and let it go until it crashes.  In 32-bit versions of QB64, I'd bet for an "out of memory" error before it gets to 1.5GB usage.  (Have Task Manager up as well, and you can watch the size there constantly increase until crashage as well.)

For anything more than 1GB, I'd recommend using the 64-bit version of QB64.  Why your 32-bit version is crashing at 500MB is beyond me.  I've never had a program give me the "out of memory" issue, without using over 1GB RAM before.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Memory allocation issue in windows with QB64
« Reply #12 on: September 11, 2018, 01:07:20 am »
Cobalts code did get Out of Memory for me in the Beta 32 Version on Windows 10.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Memory allocation issue in windows with QB64
« Reply #13 on: September 11, 2018, 11:59:06 am »
Run it and let it go until it crashes.  In 32-bit versions of QB64, I'd bet for an "out of memory" error before it gets to 1.5GB usage.  (Have Task Manager up as well, and you can watch the size there constantly increase until crashage as well.)

For anything more than 1GB, I'd recommend using the 64-bit version of QB64.  Why your 32-bit version is crashing at 500MB is beyond me.  I've never had a program give me the "out of memory" issue, without using over 1GB RAM before.

program illegal function calls at 2,150,000,000 although in task manager never uses more than 32megs ram.
Granted after becoming radioactive I only have a half-life!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Memory allocation issue in windows with QB64
« Reply #14 on: September 11, 2018, 02:25:49 pm »
Code: QB64: [Select]
  1. TYPE FileDatabase
  2.  NameL AS STRING * 256
  3.  Directory AS STRING * 256
  4.  Size AS SINGLE
  5.  DateStamp AS STRING * 10
  6.  TimeStamp AS STRING * 8
  7.  IS_Directory AS _BYTE
  8.  IS_File AS _BYTE
  9.  
  10. DIM SHARED FF(770000) AS FileDatabase
  11.  

Steve, is there anyway I could just put that TYPE record straight into a MEM block or would I have to put each element in one at a time, and handle it one element at a time while sorting?
like

_MEMPUT m, m.offset+(RecNumb&*536), FF(RecNumb&)

or would it need to be

_MEMPUT m, m.offset+(RecNumb&*536), FF(RecNumb&).NameL
_MEMPUT m, m.offset+(RecNumb&*536)+256, FF(RecNumb&).Directory
_MEMPUT m, m.offset+(RecNumb&*536)+512, FF(RecNumb&).Size
_MEMPUT m, m.offset+(RecNumb&*536)+516, FF(RecNumb&).DateStamp
_MEMPUT m, m.offset+(RecNumb&*536)+526, FF(RecNumb&).TimeStamp
_MEMPUT m, m.offset+(RecNumb&*536)+534, FF(RecNumb&).IS_Directory
_MEMPUT m, m.offset+(RecNumb&*536)+535, FF(RecNumb&).IS_File

Granted after becoming radioactive I only have a half-life!