Hello,
What is the limit on 2D char arrays (arrays of strings) in sourcemod? How can this limit be changed?
I found that declaring a static array of 2000 16-char strings (~32 KB) causes run-time failure, but 1000 16-char strings works (~16 KB). This seems odd to me - 32 KB is really not very much.
Example code:
Plugin 1 (compiles and works):
PHP Code:
#include <sourcemod>
public Plugin myinfo =
{
name = "Array_Test_1",
author = "Haytil",
description = "Demonstrates success/failure of large 2D arrays..",
version = "1.0",
url = "http://www.sourcemod.net"
};
public void OnPluginStart()
{
PrintToServer("Starting Array Test 1 plugin...");
RegAdminCmd("test_command", Test_Command, ADMFLAG_KICK, "Tests calling a sub-function which declares a 2D array.");
}
public void Update_Database(int i_Client, int i_Output_Level)
{
char temp_ids[1000][16];
}
public Action Test_Command(int client, int args)
{
Update_Database(client, 1);
return Plugin_Handled;
}
Plugin 2 (compiles but does NOT work):
PHP Code:
#include <sourcemod>
public Plugin myinfo =
{
name = "Array_Test_2",
author = "Haytil",
description = "Demonstrates success/failure of large 2D arrays..",
version = "1.0",
url = "http://www.sourcemod.net"
};
public void OnPluginStart()
{
PrintToServer("Starting Array Test 2 plugin...");
RegAdminCmd("test_command", Test_Command, ADMFLAG_KICK, "Tests calling a sub-function which declares a 2D array.");
}
public void Update_Database(int i_Client, int i_Output_Level)
{
char temp_ids[2000][16];
}
public Action Test_Command(int client, int args)
{
Update_Database(client, 1);
return Plugin_Handled;
}
When I run the above plugin, I get the following error in console:
[SM] Exception reported: Instruction contained invalid parameter
How can I avoid this, if I want to handle a large number of strings?