PDA

View Full Version : AMX Size [Header/Code/...]


Dayrion
02/07/2017, 03:18 PM
Hello.
We are few developer who works on a new gamemode whith the idea of an old gamemode (both are private).
We faced up to on a problem about compiler infos. We are like 25-30% of the new gamemode.
The oldgame compile with those infos:
Header size: 22200 bytes
Code size: 6054788 bytes
Data size: 10716556 bytes
Stack/heap size: 50000 bytes; estimated max. usage=12298 cells (49192 bytes)
Total requirements:16843544 bytes

There is no optimization and no new usefull include are used (foreach, zcmd, ...).
So.. The new gamemode have this:
Header size: 15744 bytes
Code size: 1027576 bytes
Data size: 6641048 bytes
Stack/heap size: 16384 bytes; estimated max. usage=2363 cells (9452 bytes)
Total requirements: 7700752 bytes
#include "..\includes\a_mysql" // R41 https://github.com/pBlueG/SA-MP-MySQL/
#include "..\includes\streamer" // 2.8.2 https://github.com/samp-incognito/samp-streamer-plugin/
#include "..\includes\sscanf2" // 2.8.2 https://github.com/maddinat0r/sscanf/
#include "..\includes\izcmd" // 0.2.3.0 http://forum.sa-mp.com/showthread.php?p=3475795
#include "..\includes\colandreas" // 1.4.0 https://github.com/Pottus/ColAndreas/
#include "..\includes\mSelection" // 1.1 http://forum.sa-mp.com/showthread.php?t=407045
#include "..\includes\YSF" // R19 http://forum.sa-mp.com/showthread.php?t=513499
#include "..\includes\YSI\YSI_data\y_foreach"
I'm posting here because I found this http://forum.sa-mp.com/showpost.php?p=3799506&postcount=2 from Vince.

I think the problem come from a lot of Iterator + 2D / 3D arrays (we don't use 4D arrays since it's too heavy). Have you any ideas, tips or something?

Dayrion
03/07/2017, 08:40 AM
Bump!

Freedom.
03/07/2017, 03:31 PM
If there is no lag and too much memory usage, It'll be no problem.

Here is mine: (optimized)

Header size: 19516 bytes
Code size: 1584804 bytes
Data size: 3456804 bytes
Stack/heap size: 16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements: 5077508 bytes

GoldenLion
03/07/2017, 06:42 PM
Just don't make large local arrays or if you still need to then use packed arrays.

Dayrion
04/07/2017, 02:43 AM
I think Iterators are the main source of this problem.
I'll use a for loop with the classic boolean "IsCreated" in the enum of the variable.

Beryllium
04/07/2017, 05:07 AM
Totally, It happened to me before, It completely means that you've reached the limit of string size, I am not sure of that but when it was happening to me, I tried that an it works.

Dayrion
04/07/2017, 02:26 PM
Totally, It happened to me before, It completely means that you've reached the limit of string size, I am not sure of that but when it was happening to me, I tried that an it works.

Iterator was the problem?

GoldenLion
04/07/2017, 02:45 PM
Iterator was the problem?
There's nothing to do with the iterators. One thing that most people do is save player's stats on disconnect so it's a long query and they use like 2048 cells. Just use packed arrays or don't make them too big and you are good.

Dayrion
04/07/2017, 02:54 PM
There's nothing to do with the iterators. One thing that most people do is save player's stats on disconnect so it's a long query and they use like 2048 cells. Just use packed arrays or don't make them too big and you are good.

No'p. As I said previously, I already optimized all of my "string". This is the most important part of optimization.

new query[75];
new query[220];
new query[100];
...
I'm pointing the fact I'm using Iterator because I've a lot of Iterator (single/multi dimensions). In ******'s include internal, it's creating also array (for multi-dimensional array, it's bigger : size1 + size2)
Soo.. I've a lot of multi-dimensional array with, sometimes, a big size (1300 for MAX_VEHICLES). At the end, that take a lot of memory usage/...

Beryllium
04/07/2017, 03:36 PM
There's nothing to do with the iterators. One thing that most people do is save player's stats on disconnect so it's a long query and they use like 2048 cells. Just use packed arrays or don't make them too big and you are good.

That's what was I am talking about. Almost after 1150 cell, You will have this problem.

NaS
04/07/2017, 06:45 PM
No'p. As I said previously, I already optimized all of my "string". This is the most important part of optimization.

new query[75];
new query[220];
new query[100];
...
I'm pointing the fact I'm using Iterator because I've a lot of Iterator (single/multi dimensions). In ******'s include internal, it's creating also array (for multi-dimensional array, it's bigger : size1 + size2)
Soo.. I've a lot of multi-dimensional array with, sometimes, a big size (1300 for MAX_VEHICLES). At the end, that take a lot of memory usage/...

The Iterators are global and do not affect the size of the stack. And the Data Size (this is where global Variables and Arrays are stored) is also not even close to what some modes use (and they work totally fine).

Your stack/heap est. max usage is also not very high, you didn't even use #pragma dynamic..