Author Topic: About _MEMPUT  (Read 2527 times)

0 Members and 1 Guest are viewing this topic.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
About _MEMPUT
« on: December 21, 2020, 12:15:37 am »


Code: QB64: [Select]
  1. _MEMPUT memoryBlock, bytePosition, sourceVariable [AS type]

What is the largest value for bytePosition?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: About _MEMPUT
« Reply #1 on: December 21, 2020, 01:07:46 am »
M.SIZE

How big is your memblock?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SquirrelMonkey

  • Newbie
  • Posts: 29
  • Youtuber and GIPHY artist
    • View Profile
    • Joluijten.com
Re: About _MEMPUT
« Reply #2 on: December 21, 2020, 01:19:11 am »
Not sure if this works, because I have no idea what that line of code exactly does, but my QuickBASIC solution (that worked for DIM, SOUND, etc.) was this...
I would raise the value step by step and add an "ON ERROR GOTO DOH:"-line. If the program goes to DOH: your former value was the highest possible value.

I know that some forum members are crying now. Sorry.
« Last Edit: December 21, 2020, 01:22:57 am by SquirrelMonkey »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: About _MEMPUT
« Reply #3 on: December 21, 2020, 02:12:43 am »
Not sure if this works, because I have no idea what that line of code exactly does, but my QuickBASIC solution (that worked for DIM, SOUND, etc.) was this...
I would raise the value step by step and add an "ON ERROR GOTO DOH:"-line. If the program goes to DOH: your former value was the highest possible value.

I know that some forum members are crying now. Sorry.

These type of questions have a specific size, but it’s determined by the user and their computer’s memory.

DIM M AS _MEM
M = _MEMNEW(1000000000)

There’s a 1GB memblock defined.  The upper limit of it would be byte 999999999, as we start counting at 0.

DIM Example(1000) AS INTEGER
DIM M AS _MEM
M = _MEM(Example())

The last byte here is going to be 2001.  Integers take up 2 bytes in memory, and we just pointed to an array of 1001 elements, which use 2002 bytes of memory.  The last byte is going to be 2001, as we start counting at zero, again.

It all depends on what we’re pointing _MEM at, or how large we define it.

Largest memblock I’ve used to date was 22GB in size, and that was to load a whole database into memory at once, and it worked fine on my PC with 64GB of ram, but died horribly on my laptop with only 16GB memory...

You limit will be defned by your available memory and what you define it as, and to get that limit, just use M.SIZE, as I mentioned above.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!