Fix memory leak and possible crash
nr_dlsim allocates memory on every SNR iteration without freeing it. This can lead to memory exhaustion. Fix this by allocating only once and reuse memory. Also, free it before exit.
This commit is contained in:
@@ -959,6 +959,13 @@ printf("%d\n", slot);
|
||||
fprintf(csv_file,"avg_round,eff_rate,eff_throughput,TBS\n");
|
||||
}
|
||||
//---------------
|
||||
|
||||
Sched_INFO = malloc(sizeof(*Sched_INFO));
|
||||
if (Sched_INFO == NULL) {
|
||||
LOG_E(PHY, "out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (SNR = snr0; SNR < snr1 && !stop; SNR += .2) {
|
||||
|
||||
varArray_t *table_tx=initVarArray(1000,sizeof(double));
|
||||
@@ -1012,11 +1019,6 @@ printf("%d\n", slot);
|
||||
UE_harq_process->DLround = round;
|
||||
UE_harq_process->first_rx = 1;
|
||||
|
||||
Sched_INFO = malloc(sizeof(*Sched_INFO));
|
||||
if (Sched_INFO == NULL) {
|
||||
LOG_E(PHY, "out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
memset(Sched_INFO, 0, sizeof(*Sched_INFO));
|
||||
Sched_INFO->sched_response_id = -1;
|
||||
|
||||
@@ -1335,6 +1337,8 @@ printf("%d\n", slot);
|
||||
n_errs = n_errors[0];
|
||||
} // NSR
|
||||
|
||||
free(Sched_INFO);
|
||||
|
||||
free_channel_desc_scm(gNB2UE);
|
||||
|
||||
for (i = 0; i < n_tx; i++) {
|
||||
|
||||
Reference in New Issue
Block a user