# Why do GPUs have limited amount of allocations?

I've been learning Vulkan lately and I read that you can allocate VRAM memory only set amount of times and it doesn't matter if it's 2gb or 2kb, why is it?

I'm specifically referring to VkPhysicalDeviceLimits structure which has a field maxMemoryAllocationCount.

• It might be helpful if you provided a source for that claim; it's most definitely not true so it would be a good opportunity to clear some things up. – Maximus Minimus Sep 23 '18 at 19:18
• Well VkPhysicalDeviceLimits structure has a field maxMemoryAllocationCount so I guess it's real – Werem Sep 23 '18 at 19:20
• khronos.org/registry/vulkan/specs/1.1-extensions/man/html/… - "maxMemoryAllocationCount is the maximum number of device memory allocations, as created by vkAllocateMemory, which can simultaneously exist" - the "which can simultaneously exist" part is important here. – Maximus Minimus Sep 23 '18 at 19:25
• See also: khronos.org/registry/vulkan/specs/1.1-extensions/man/html/… - "The maximum number of valid memory allocations that can exist simultaneously within a VkDevice may be restricted by implementation- or platform-dependent limits." – Maximus Minimus Sep 23 '18 at 19:26
• @MaximusMinimus I'd upvote an answer clearly explaining the "which can simultaneously exist" distinction and laying out what this limitation means / why it's there. – DMGregory Sep 23 '18 at 23:55

It's not correct to say that - as a general case - GPUs have a fixed limit on the number of allocations that may be made.

What the Vulkan documentation for VkPhysicalDeviceLimits specifies is that:

maxMemoryAllocationCount is the maximum number of device memory allocations, as created by vkAllocateMemory, which can simultaneously exist.

The key destinction here is that the limit only applies to allocations that can simultaneously exist. For example, if the maximum is 256, and if you have 256 simultaneous allocations, then you've obviously hit that maximum. However, if you subsequently free 128 of those, then you can obviously make a further 128 new allocations.

If we drill down further into the documentation for vkAllocateMemory, we find the following statement:

The maximum number of valid memory allocations that can exist simultaneously within a VkDevice may be restricted by implementation- or platform-dependent limits.

This therefore tells us that the limit may be imposed by the hardware, by the driver or by the underlying OS, but also that in some cases there may not be such a limit.

Looking further at https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html in "Table 48. Required Limits" we find the entry for maxMemoryAllocationCount and we see that it specifies a required minimum value of 4096, with no specified maximum.

From this we can say that a Vulkan device is required to support at least 4096, but (once more) may also have no limit on the count of, simultaneous allocations.

This is obviously to enable Vulkan to be implemented on the widest possible range of hardware; hardware where such limits might exist and hardware where they might not.

To wrap it all up.

• Vulkan allows for the capability of drivers to restrict the number of simultaneous allocations that may exist.
• This restriction is just on the number of simultaneous allocations, not the absolute number of total allocations.
• Vulkan also allows for this number to be unrestricted.
• Whether the number is restricted or not depends on the individual implementation.
• This is a Vulkan-specific feature which may not exist in other APIs.