Skip to content

Commit

Permalink
Use atexit hook to avoid leaking memory
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed Jul 11, 2024
1 parent a29ea1f commit 47702b4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/variorum/Intel_GPU/intel_gpu_power_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ static char m_hostname[1024];
static double *m_initial_energy_for_gpu;
static int *m_init_energy;

void releaseInitialEnergyForGPU()
{
free(m_initial_energy_for_gpu);
free(m_init_energy);
}

void initAPMIDG(void)
{
int verbose = 0;
Expand All @@ -43,7 +49,7 @@ void initAPMIDG(void)
m_initial_energy_for_gpu = (double *) malloc(sizeof(double) *
m_total_unit_devices);
m_init_energy = (int *) calloc(m_num_package, sizeof(int));

atexit(releaseInitialEnergyForGPU);
init = 1;
}

Expand Down

0 comments on commit 47702b4

Please sign in to comment.