Skip to content

Calling initializeVkFFT causes memory leak #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
laomagood opened this issue Dec 5, 2024 · 2 comments
Open

Calling initializeVkFFT causes memory leak #194

laomagood opened this issue Dec 5, 2024 · 2 comments

Comments

@laomagood
Copy link

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);
}
`

@laomagood
Copy link
Author

The program runs under OpenCL

DTolm added a commit that referenced this issue Mar 16, 2025
-Fixes two memory leaks and incorrect indexing when using multiple buffers
@DTolm
Copy link
Owner

DTolm commented Mar 16, 2025

Hello,

The full description of the issue was provided by #197 and it should be fixed now. Sorry for the long wait, I am working fully on another project currently, but will come back to VkFFT soon.

Best regards,
Dmitrii

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants