Memory

Variables are allocated in memory blocks. The default size is "4096" bytes
per block. Up to 64 blocks can be used. Nano allocates the needed blocks
automatically. If you need more memory, you can increase the blocksize
with the "membsize" register.

Arrays are allocated as their own block. So "membsize" has no effect on them.


Virtual memory

On machines without a MMU you can use the built in virtual memory driver.
Note: only arrays can be used with VM!

You have to set the path, where the swapfile will be created:

Set a "NANOTEMP" environment variable to the directory.

PC: set nanotemp=%TEMP%\vm_

Amiga: setenv nanotemp "T:vm_"

Nano adds the current time to the filename: "vm_hhmmss".

The following registers are important:

"vmuse" must be set to "1" to enable VM.

"vmbsize" the swapfile size in bytes. The default is "1048576" bytes (1 MB).
Just multiply with a factor to increase.

"vmcachesize" the cachesize for array elements. The default is "1024".

Note: The long registers L32 - L35 are used to store the values.
You should only use the range L0 - L31 for your data!

Limits: The swapfile is limited to 2048 MB. This shouldn't be a problem ;-).

Example:
     #include <vm.nah>                      sets the register names

     push_i      1, vmuse;                  switch vm on

     push_i      256, L0;
     mul_l       vmbsize, L0, vmbsize;      set 256 MB for swapfile

     push_i      10000, vmcachesize;        cache for 10000 elements
     
Prev: Files error codes | Next: Memory error codes