Skip to content

Calling initializeVkFFT causes memory leak #194

@laomagood

Description

@laomagood

Hello:
I have many different configurations for configuration.size[0] and configuration.numberBatches. I saved these configurations and repeatedly load them and call initializeVkFFT. However, I noticed that calling initializeVkFFT causes memory leaks. I wrote a test code and found that when configuration.size[0] = 9200 and configuration.numberBatches = 640, running it 10,000 times results in 1253.9MB of memory not being released.

`VkFFTResult testVkFFT(VkGPU* vkGPU)
{
int cols = 9200;
int rows = 640;

VkFFTConfiguration configuration = {};
VkFFTApplication app = { };

configuration.FFTdim = 1;
configuration.size[0] = cols;
configuration.numberBatches = rows;

configuration.device = &vkGPU->device();
configuration.context = &vkGPU->context();

uint64_t bufferSize = (uint64_t)4 * 2 * cols * rows;
configuration.bufferSize = &bufferSize;

configuration.loadApplicationFromString = 1;

if (configuration.loadApplicationFromString) {
    FILE* kernelCache;
    uint64_t str_len;
    char fname[500];
    int VkFFT_version = VkFFTGetVersion();
    sprintf(fname, "vkFFT");
    kernelCache = fopen(fname, "rb");
    if (!kernelCache)
        return VKFFT_ERROR_EMPTY_FILE;
    fseek(kernelCache, 0, SEEK_END);
    str_len = ftell(kernelCache);
    fseek(kernelCache, 0, SEEK_SET);
    configuration.loadApplicationString = malloc(str_len);
    fread(configuration.loadApplicationString, str_len, 1, kernelCache);
    fclose(kernelCache);
}


VkFFTResult resFFT = initializeVkFFT(&app, configuration);
if (resFFT != VKFFT_SUCCESS) {
    return resFFT;
}

if (configuration.loadApplicationFromString) {
    free(configuration.loadApplicationString);
}

deleteVkFFT(&app);
return VKFFT_SUCCESS;

}

saveVkFFT(&gpu);

int size = 10000;
for(int i=0; i<size; i++) {
showProgressBar(i, size);
testVkFFT(&gpu);
}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions