pragma dynamic
#1

Hi, actually I didn't know what to call the thread, but I had to use pragma dynamic like two days ago after adding a few hundreds lines of code because some things stopped working and this appeared after compiling:
Код:
Header size:          12368 bytes
Code size:           741164 bytes
Data size:         11006392 bytes
Stack/heap size:      16384 bytes; estimated max. usage=4924 cells (19696 bytes)
Total requirements:11776308 bytes
So I started thinking of optimizing my code, but I don't know what could cause that stuff. I heard it's caused by some large arrays, but I always get a proper size for local arrays so I don't think it could be the problem. But I have some bigger global arrays (I think they are big) like
Код:
new Injuries[MAX_PLAYERS][39][MAX_BODY_PARTS];
but I can't remove them. Anyways what could the reasons be? I tried googling and looking at the optimization tutorials as well.
Reply
#2

Read a recent thread about it and it had a link to Emmet explaining a bit about it but can't find it atm as I'm on phone. I'd say try to see if you have some variables/arrays having too big sizes. They are mostly known as like "MAX_FACTIONS" etc, those you created yourself. Referencing to what Emmet said, there's no need to have something like that being defined as 10000 when you are going to only have like 10 factions max. Hope this made sense, so start looking there.
Reply
#3

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Read a recent thread about it and it had a link to Emmet explaining a bit about it but can't find it atm as I'm on phone. I'd say try to see if you have some variables/arrays having too big sizes. They are mostly known as like "MAX_FACTIONS" etc, those you created yourself. Referencing to what Emmet said, there's no need to have something like that being defined as 10000 when you are going to only have like 10 factions max. Hope this made sense, so start looking there.
You mean this thread?

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

It was explained when these warnings can show up. Either big arrays with big cell sizes are created or pawno is being used with parameters such as -v or -3d. I thought GoldenLion already understood what to do because he already participated in the thread discussion.
Reply
#4

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Read a recent thread about it and it had a link to Emmet explaining a bit about it but can't find it atm as I'm on phone. I'd say try to see if you have some variables/arrays having too big sizes. They are mostly known as like "MAX_FACTIONS" etc, those you created yourself. Referencing to what Emmet said, there's no need to have something like that being defined as 10000 when you are going to only have like 10 factions max. Hope this made sense, so start looking there.
I always get a proper size for an array so it shouldn't be a problem. I read this: https://sampforum.blast.hk/showthread.php?tid=480439 so I'll go and try packed arrays.
Reply
#5

How is MAX_BODY_PARTS defined and how do you use

Код:
new Injuries[MAX_PLAYERS][39][MAX_BODY_PARTS];
?
Reply
#6

MAX_BODY_PARTS is 7 because there are only 7 body parts in SA-MP and how I use it is
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    Injuries[playerid][weaponid][bodypart - 3]++;
    return 1;
}
Reply
#7

Well that is 136500 cells so to some extent I suppose that it is a very big one. Perhaps try to reduce the 39 and not save as many damages? If you think about it the smallest amount of damage (by default) is I believe silencer, when speaking of guns not melee objects, and I believe it takes down 20 health. 200 / 20 = 10, 200 because health + armor. So perhaps only save 10? That way you would reduce it to 35000, this of course given that your MAX_PLAYERS is 500 which I just assumed.

I'm purly guessing by the way, don't write it in stone but I guess it's worth a try?
Reply
#8

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Well that is 136500 cells so to some extent I suppose that it is a very big one. Perhaps try to reduce the 39 and not save as many damages? If you think about it the smallest amount of damage (by default) is I believe silencer, when speaking of guns not melee objects, and I believe it takes down 20 health. 200 / 20 = 10, 200 because health + armor. So perhaps only save 10? That way you would reduce it to 35000, this of course given that your MAX_PLAYERS is 500 which I just assumed.

I'm purly guessing by the way, don't write it in stone but I guess it's worth a try?
My MAX_PLAYERS is 30 and it doesn't save the damages, but the amount of times you got hit. :P
Reply
#9

only local arrays do that and many many call levels like a calls b, b calls c, c calls d, ..., y calls z
Reply
#10

You would be better off saving all this to database then all you have to do is save the player, weapon, bodypart and create the appropriate queries instead of swamping yourself with shit loads of generally unused arrays. Think about design here your design is out to lunch then some and those design flaws will echo in all your other code.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)