Skip to content
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

Potential Memory Leak when enabling Validation Layers #6033

Closed
youss2017 opened this issue Jun 19, 2023 · 3 comments
Closed

Potential Memory Leak when enabling Validation Layers #6033

youss2017 opened this issue Jun 19, 2023 · 3 comments

Comments

@youss2017
Copy link

youss2017 commented Jun 19, 2023

Environment:

  • OS: Windows 11 Version 22H2 (OS Build 22621.1702)
  • GPU: Radeon RX 6700 XT AMD Driver Version 23.4.2; Released 4/12/2023
  • SDK or header version if building from repo: 1.3.239.0
  • Options enabled (synchronization, best practices, etc.): VK_EXT_debug_utils; VK_LAYER_KHRONOS_validation;ValidationFeatureEnableEXT::eSynchronizationValidation

When creating and freeing a VkCommandPool, the application's memory usages continues to rise without returning to original usage after calling vkDestroyCommandPool. This appears to be a memory leak. Note, that this only happens once Validation Layers and ValidationFeatureEnableEXT::eSynchronizationValidation are enabled.

	vk::Device device = ctx->Device;
	while (true) {
#if 1
		vk::CommandPool pool = device.createCommandPool({});
		vk::CommandBuffer cmd = device.allocateCommandBuffers(vk::CommandBufferAllocateInfo(pool, vk::CommandBufferLevel::ePrimary, 1))[0];
		device.destroyCommandPool(pool);
#else
		VkCommandPool pool;
		VkCommandBuffer cmd;

		VkCommandPoolCreateInfo createInfo{ VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO };
		createInfo.queueFamilyIndex = ctx->GraphicsQueueFamilyIndex;
		vkCreateCommandPool(device, &createInfo, nullptr, &pool);
		VkCommandBufferAllocateInfo cmdAllocate{ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO };
		cmdAllocate.commandBufferCount = 1;
		cmdAllocate.commandPool = pool;
		cmdAllocate.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
		vkAllocateCommandBuffers(device, &cmdAllocate, &cmd);

		vkDestroyCommandPool(device, pool, nullptr);
#endif
		this_thread::sleep_for(chrono::milliseconds(1));
	}

Expected behavior

The expected behavior is that once a VkCommandPool is freed, the memory should return previous state before the VkCommandPool was allocated.

code or terminal output
Validation Warning: [ UNASSIGNED-BestPractices-vkCreateDevice-deprecated-extension ] Object 0: handle = 0x21f79a74f50, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0xad32db6 | CreateDevice(): Attempting to enable deprecated extension VK_KHR_shader_non_semantic_info, but this extension has been promoted to VK_VERSION_1_3.
@juan-lunarg
Copy link
Contributor

SDK or header version if building from repo: 1.3.239.0

This is a fairly old version of the validation layers. We now run address sanitizer on CI to catch leaks and other misc. types of bugs. Are you sure this still occurs?

@youss2017
Copy link
Author

I will try updating.

@youss2017
Copy link
Author

Thanks Juan,
After updating from 1.3.239.0 to 1.3.250.0 the memory leak no longer occurs.

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