Two-dimensional array limit in function?
#1

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..
Reply
#2

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?
Reply
#3

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
Reply
#4

#pragma dynamic 99999999
Reply
#5

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?
Reply
#6

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.
Reply
#7

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?
Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)