[Tutorial] Sparse arrays
#1

Sparse arrays

Introduction
Time after time, I see users using 2D or 3D arrays for string storage - which takes up a LOT of memory. This tutorial will teach you how to limit your use on sparse arrays, as well as save memory in your script.

What is a sparse array?
A sparse array is a multidimensional array which often has most of it's data empty, but it still takes up lots of memory.

Consider this code:

pawn Код:
#define MAX_ITEMS (128)

new g_String[MAX_ITEMS][64];
This array alone is a total of 8,192 cells - which is 32,768 bytes (32 kilobytes). For example, if you are only using 10/128 items, you are using 2,560 bytes, but there's still 29,208 bytes being unused!

However, since we're using global variables, this memory isn't allocated in any way, but the memory is dumped in the assembly line, which makes the .amx size larger in size.

The following data is dumped on the stack:

Код:
DUMP          200 2fc 3f8 4f4 5f0 6ec 7e8 8e4 9e0 adc bd8 cd4 dd0 ecc fc8 10c4
DUMP          11c0 12bc 13b8 14b4 15b0 16ac 17a8 18a4 19a0 1a9c 1b98 1c94 1d90 1e8c 1f88 2084
DUMP          2180 227c 2378 2474 2570 266c 2768 2864 2960 2a5c 2b58 2c54 2d50 2e4c 2f48 3044
DUMP          3140 323c 3338 3434 3530 362c 3728 3824 3920 3a1c 3b18 3c14 3d10 3e0c 3f08 4004
DUMP          4100 41fc 42f8 43f4 44f0 45ec 46e8 47e4 48e0 49dc 4ad8 4bd4 4cd0 4dcc 4ec8 4fc4
DUMP          50c0 51bc 52b8 53b4 54b0 55ac 56a8 57a4 58a0 599c 5a98 5b94 5c90 5d8c 5e88 5f84
DUMP          6080 617c 6278 6374 6470 656c 6668 6764 6860 695c 6a58 6b54 6c50 6d4c 6e48 6f44
DUMP          7040 713c 7238 7334 7430 752c 7628 7724 7820 791c 7a18 7b14 7c10 7d0c 7e08 7f04
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DUMP          0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Stack and heap
I won't be going into full detail here, since it's explained in detail in the PAWN Implementers Guide.

The "stack/heap" is simply part of the abstract machine that runs PAWN scripts, which controls and manipulates allocated memory from local variables. Very often, people find themselves using so much heap space that they end up running out and resort to using a "#pragma" instruction - but this is bad pratice!

Consider this variable:

pawn Код:
main()
{
    new var;
}
That variable alone is 1 cell (4 bytes). Arrays are basically "many cells in one", so the bigger array, the more memory you're allocating on the stack.

Local variables
Local variables are simply variables created within other functions or statements. When a function is called, that memory is allocated and used accordingly. On the other hand, global variables are not counted on the stack or heap - but they affect .amx size due to the memory dumps in the assembly line.

Why shouldn't I use a sparse array?
Sparse arrays shouldn't be used because they add unnecessary memory usage to scripts, which take up the heap space (mentioned above). There are much more better ways to store string data.
  • Packed arrays

    Packed arrays store data in each byte, rather than each cell, saving you 4 times less the memory.

    Consider this code:

    pawn Код:
    #define MAX_ITEMS (128)

    new g_String[MAX_ITEMS][64 char];
    This will allocate 2,048 cells on the stack (8,192 bytes, which is a reduction 7 kilobytes!). This isn't as much as bad as regular arrays, but packed arrays were designed for a reason!

    The following methods are ways to manipulate "dynamic memory" in PAWN without touching the stack or heap, but they also allocate memory regardless:

  • Linked lists

    A linked list is a data structure which consists of several nodes, all which represent a special sequence. Each node is composed of a data and a reference to the next node in the sequence.

    There is a library by BigETI that allows the possibility of linked lists in PAWN (frankly, I can't think of anymore). You can find it here:

    https://sampforum.blast.hk/showthread.php?tid=451962

  • Data containers

    A data container allows dynamic memory to be allocated, without having to specify a size for them. This data uses an internal linked list system (as far as I know, correct me if I'm wrong) and it doesn't take up any memory on the stack or heap.

    Here's a plugin for data containers:

    https://sampforum.blast.hk/showthread.php?tid=238844

  • Memory access plugin

    This plugin also allows you to dynamically allocate memory during runtime. It was created by BigETI.

    https://sampforum.blast.hk/showthread.php?tid=451381

  • y_malloc

    There's also y_malloc from YSI, which allows dynamic memory allocation too. It was created by ******.

    https://sampforum.blast.hk/showthread.php?tid=58827

  • Per-player variables

    For example, if you have an array like this:

    pawn Код:
    new g_JailReason[MAX_PLAYERS][128];
    If MAX_PLAYERS is 500, then that's 64,000 cells allocated (256,000 bytes, that's 250 kilobytes) onto the stack! I've seen LOADS of people do this before, so I'm not surprised.

    This is where per-player variables come in! Per-player variables are slower than variables in PAWN, but in this case, you do need them!

  • GVar plugin

    Similar to the same scenario above, however you are not dealing with players. It is not really necessary to use the GVar plugin, but it's just added for the sake of completing this tutorial.

    https://sampforum.blast.hk/showthread.php?tid=151076
Conclusion
This is a small tutorial, but at least you've learned something useful from it today!

Feel free to correct me on any parts of this tutorial that I have explained incorrectly, or not thorough enough.

Edit: Thanks to ****** for reminding me about global variables! It was 4 AM when I originally made this tutorial so that would explain why some parts are not properly explained.
Reply


Messages In This Thread
Sparse arrays - by Emmet_ - 10.12.2013, 19:12
AW: Sparse arrays - by BigETI - 10.12.2013, 19:40
Re: Sparse arrays - by Emmet_ - 10.12.2013, 19:51
Re: Sparse arrays - by Patrick - 10.12.2013, 20:01
Re: Sparse arrays - by iZN - 10.12.2013, 20:08
Re: Sparse arrays - by Luis- - 10.12.2013, 21:41
Re: Sparse arrays - by Emmet_ - 10.12.2013, 23:19
Re: Sparse arrays - by Emmet_ - 10.12.2013, 23:42

Forum Jump:


Users browsing this thread: 3 Guest(s)