Saving memory
#1

Hi

When in my server are connected 30+ players and when the server is on from hours, sometimes I am forced to restart the server because everything don't work. With everything I mean all the things that are scripted and so commands, functions, timers and things like that. This starting to happen when I have released the new update of the gamemode and in this update I have inserted a lot of very huge strings which are formatted at the very start of the gamemode to be used in some dialogs.

Only those strings use this memory:

PHP код:
Header size:            824 bytes
Code size
:           136648 bytes
Data size
:           816464 bytes
Stack
/heap size:      16384 bytesestimated maxusage=50 cells (200 bytes)
Total requirements:  970320 bytes 
So I've decided to split them from the gamemode and put them in a fs and I can say that the situation is better than before but the problem still happen.

These are the warnings I get on server-log.txt when everything get buggy and they are really much (you can see from timestamp how much they are).


PHP код:
[13:09:48] [debugRun time error 8"Heap underflow"
[13:09:48] [debug]  Heap pointer (HEAis 0xB36AA908heap bottom (HLWis 0x3D9C50
[13:09:48] [debugAMX backtrace:
[
13:09:48] [debugRun time error 8"Heap underflow"
[13:09:48] [debug]  Heap pointer (HEAis 0xB36AA908heap bottom (HLWis 0x3D9C50
[13:09:48] [debugAMX backtrace:
[
13:09:48] [debugRun time error 8"Heap underflow"
[13:09:48] [debug]  Heap pointer (HEAis 0xB36AA908heap bottom (HLWis 0x3D9C50 
So now my aim is trying to save as memory as I can and so have you got some advice for me?

I've also tried BitArrays to reduce the bytes of bools but idk why but I experienced an increment on the output of pawno.

This is the one from the gamemode:
PHP код:
Header size:          21456 bytes
Code size
:          1495220 bytes
Data size
:          2086112 bytes
Stack
/heap size:      16384 bytesestimated maxusageunknowndue to recursion
Total requirements
3619172 bytes 
I've also read to use
PHP код:
#pragma dynamic 1000000 
but I'm not sure that this can help me. What do you think about?




Those are the new strings I've put on the FS:
PHP код:
enum DialogsFame
{
    
vagos1[433],
    
vagos2[1445],
    
vagos3[921],
    
grove1[714],
    
grove2[1530],
    
grove3[959],
    
dss1[489],
    
dss2[2241],
    
dss3[2290],
    
dss4[1383],
    
tf1[466],
    
tf2[903],
    
fbi1[332],
    
fbi2[2087],
    
rog1[451],
    
rog2[1556],
    
marines1[666],
    
marines2[2041],
    
marines3[1907],
    
marines4[862],
    
mercenari1[926],
    
mercenari2[2133],
    
mercenari3[2195],
    
cov1[354],
    
cov2[904],
    
sef1[412],
    
sef2[1177],
    
ius1[313],
    
ius2[591],
    
kdg1[335],
    
kdg2[1261],
    
rainbow1[2096],
    
rainbow2[792],
    
bom1[381],
    
bom2[1563],
    
bom3[1891],
    
daedric1[1964],
    
daedric2[1975],
    
daedric3[2130],
    
daedric4[2454],
    
dragons1[1735],
    
fighters1[483],
    
fighters2[2106],
    
fighters3[2206],
    
fighters4[2120],
    
polizia1[1117],
    
polizia2[2043],
    
polizia3[2042],
    
polizia4[1958],
    
polizia5[1971],
    
polizia6[1847],
    
qq1[2629],
    
hunter1[545],
    
hunter2[1965],
    
hunter3[2085],
    
hunter4[654],
    
bos1[381],
    
bos2[1856],
    
bos3[1889],
    
commander1[469],
    
commander2[1783],
    
commander3[1425],
    
fdr1[968],
    
fdr2[1967],
    
fdr3[2106],
    
fdr4[1980],
    
fdr5[2058],
    
fdr6[2167]
}
new 
DialogsClan[DialogsFame]; 
I know, I know... They are really really really much but I don't know how to substitute them.

At very start I've tried to put them just when a player open the dialog and so I didn't make them global but this way is very laggy because I've experienced a huge increment on packet-loss of the players (because I have to create a new huge string and format it everytime a player make the command or just go forward in the dialog by pressing "forward" or "back").

I've read that enums are easy to use but they're not good to save memory.. So could be a good deal remove that enum and make something like "new vagos1[433], new vagos2[1445], etc.;"?

Or I am forced to put them only when a player open the dialog? Maybe I can just use a single string like new alldialogs[2453]; and format it everytime the player open the dialog or just go forward.

I just need some advice or some opinions.. Could be really useful


Thank you really much
Reply
#2

You are putting megabytes of data on-hold in hopes of someone using it later? specially some dialogs which one might not use for hours.
Format these whenever they are needed so these memory cells will be released whenever server is done with them.

Pragma dynamic increases the heap/stack size, it can technically solve your problem, but the what I mentioned before is the proper solution.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)