@@ -1036,7 +1036,8 @@ def __init__(self, size):
10361036 assert ("release" , NEW_HANDLE ) in calls
10371037
10381038
1039- def test_vmm_allocate_close_does_not_leak (init_cuda ):
1039+ @pytest .mark .parametrize ("grow" , [False , True ], ids = ["allocate" , "grow" ])
1040+ def test_vmm_allocate_close_does_not_leak (init_cuda , grow ):
10401041 device = Device ()
10411042 if not device .properties .virtual_memory_management_supported :
10421043 pytest .skip ("Virtual memory management is not supported on this device" )
@@ -1045,13 +1046,21 @@ def test_vmm_allocate_close_does_not_leak(init_cuda):
10451046 device ,
10461047 config = VirtualMemoryResourceOptions (handle_type = "win32_kmt" if IS_WINDOWS else "posix_fd" ),
10471048 )
1048- buf = mr .allocate (8 * 1024 * 1024 ) # Warm up and learn the aligned allocation size.
1049- aligned_size = buf .size
1050- buf .close ()
1049+ requested_size = 8 * 1024 * 1024
1050+
1051+ def allocate_and_close ():
1052+ buf = mr .allocate (requested_size )
1053+ if grow :
1054+ buf = mr .modify_allocation (buf , 2 * buf .size )
1055+ aligned_size = buf .size
1056+ buf .close ()
1057+ return aligned_size
1058+
1059+ aligned_size = allocate_and_close () # Warm up and learn the aligned allocation size.
10511060
10521061 baseline = handle_return (driver .cuMemGetInfo ())[0 ]
10531062 for _ in range (8 ):
1054- mr . allocate ( 8 * 1024 * 1024 ). close ()
1063+ allocate_and_close ()
10551064 free = handle_return (driver .cuMemGetInfo ())[0 ]
10561065
10571066 # Current main leaks aligned_size per iteration; the fixed path stays near baseline.
0 commit comments