Two-dimensional array limit in function? -
jop9888 - 15.07.2018
So, i am running into a weird problem. I am creating a two-dimensional array in a function like this:
Код:
forward TestFunc(test1);
public TestFunc(test1)
{
print("0");
new testfloat[1000][2];
print("1");
}
When i call the function via:
Код:
print("Calling TestFunc");
TestFunc(count)
print("TestFunc called");
My function crashed and i see the following in my log:
Код:
[14:04:44] Calling TestFunc
[14:04:44] 0
However, when i decrease the two-dimensional array size to [500][2] it does work, like this:
Код:
forward TestFunc(test1);
public TestFunc(test1)
{
print("0");
new testfloat[500][2];
print("1");
}
Result:
Код:
[14:05:18] Calling TestFunc
[14:05:18] 0
[14:05:18] 1
[14:05:18] TestFunc called
Can anyone tell me what is going wrong here? Creating a two-dimensional array like this as a global variable or in a DCMD funcion etc does work..
Re: Two-dimensional array limit in function? -
NaS - 15.07.2018
Pretty sure it's about the size. The first is 2000 cells which is quite big.
Did you try lowering the size in the first test?
Re: Two-dimensional array limit in function? -
jop9888 - 15.07.2018
With lower size it does work, however the compiler doesn't tell it's out of size or anything. Can't find any limits for this either
Re: Two-dimensional array limit in function? -
jlalt - 15.07.2018
#pragma dynamic 99999999
Re: Two-dimensional array limit in function? -
jop9888 - 15.07.2018
Quote:
Originally Posted by jlalt
#pragma dynamic 99999999
|
This worked, thanks mate!
Could you explain how this works? It allocates more dynamic memory or something?
Re: Two-dimensional array limit in function? -
Pottus - 15.07.2018
Quote:
Originally Posted by jlalt
#pragma dynamic 99999999
|
You should never have to do this and if you do something is wrong with what you are doing.
Re: Two-dimensional array limit in function? -
jlalt - 15.07.2018
Quote:
Originally Posted by Pottus
You should never have to do this and if you do something is wrong with what you are doing.
|
What's the issue with huge sized arrays?
The code up in this post does it look wrong?
I got 2k vehicles wanna assign two ids for each vehicle for ex playerid and his house, where's the issue here? Isn't pawn broken?
Re: Two-dimensional array limit in function? -
jop9888 - 15.07.2018
Quote:
Originally Posted by ******
No, pawn isn't broken, but it any language you shouldn't be creating huge local arrays. You need to think carefully about your algorithm and see if there is a better way.
|
I agree in general, however i will use this to analyse nodes used in GPS.dat for route calculations. Maybe i could find better ways, however this will work just fine with a little more dynamic memory.