I need to test the performance of my project on Windows.
I have an array of arrays rede_conexoes
, and allocate each position in a loop, but after some iterations the malloc
function doesn't work and abruptly stops my process, before I can even test the return value and shows no error message.
The code works perfectly fine on the WSL (Windows Subsystem for Linux) on Windows 10. To test the code natively on Windows, I installed Mingw-w64 for the gcc compiler (couldn't find a better solution, as support for OpenMP is needed).
Here is the snippet with the malloc
function:
bool **rede_conexoes = (bool**) malloc(num_PL * sizeof(bool*));
...
for(int i = 0; i < num_PL; i++){
rede_conexoes[i] = (bool*)malloc(num_PL*sizeof(bool)); // <- Error occurs here
if(rede_conexoes[i] == NULL) exit(1); // <- Can't get to this line after the error
for(int j = 0; j < num_PL; j++)
fscanf(model, "%d", (int*)&rede_conexoes[i][j]);
}
I don't understand how can this run with no issues on WSL but on Windows it crashes and there is no error message.
I noticed that it starts to fail when num_PL
is greater than 2^3 = 8
, there's no problem if num_PL
is greater than 2^15 = 32768
on Linux. I tested the .exe created by gcc on Command Prompt(cmd) and PowerShell, both with the same results.