QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Cobalt on September 10, 2018, 08:20:15 pm

Title: Memory allocation issue in windows with QB64
Post by: Cobalt 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).
Title: Re: Memory allocation issue in windows with QB64
Post by: FellippeHeitor 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.
Title: Re: Memory allocation issue in windows with QB64
Post by: bplus on September 10, 2018, 11:36:28 pm
OK here
Title: Re: Memory allocation issue in windows with QB64
Post by: FellippeHeitor on September 10, 2018, 11:40:57 pm
What system? What version of QB64? Is it Steve's mod?
Title: Re: Memory allocation issue in windows with QB64
Post by: SMcNeill 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.
Title: Re: Memory allocation issue in windows with QB64
Post by: bplus on September 10, 2018, 11:58:05 pm
Yes 64 x 64 and this: v1.2 2018 0228/86 git b30af92
Title: Re: Memory allocation issue in windows with QB64
Post by: FellippeHeitor on September 10, 2018, 11:59:12 pm
Oh, there's a screenshot.

I'm always in the "Recent posts (http://www.qb64.org/forum/index.php?action=recent)" page and don't get to see attachments unless I click the post to read it.

Ok.
Title: Re: Memory allocation issue in windows with QB64
Post by: Omerta7486 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.
Title: Re: Memory allocation issue in windows with QB64
Post by: SMcNeill 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.  ;)
Title: Re: Memory allocation issue in windows with QB64
Post by: Cobalt 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.
Title: Re: Memory allocation issue in windows with QB64
Post by: bplus 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?
Title: Re: Memory allocation issue in windows with QB64
Post by: SMcNeill 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.
Title: Re: Memory allocation issue in windows with QB64
Post by: bplus 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.
Title: Re: Memory allocation issue in windows with QB64
Post by: Cobalt 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.
Title: Re: Memory allocation issue in windows with QB64
Post by: Cobalt 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