OK
One sub to destroy the any ptr to udt
One sub to nullify the name string of any ptr to udt.
(Ran for 30 mins, no leaks)
win 10
Code: Select all
Type sysobject Extends Object
As String Name
End Type
Dim As Const String pad=String(1000,"z")
Type xyz1 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz2 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz3 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz4 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz5 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz6 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz7 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz8 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz9 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz10 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz11 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz12 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz13 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz14 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz15 Extends sysObject
As String Name
As String a(10000)
End Type
Type xyz16 Extends sysObject
As String Name
As String a(10000)
End Type
Sub destroy(Byref p As Any Ptr)
Var t=Cast(Object Ptr,p)
If *t Is xyz1 Then Delete Cast(xyz1 Ptr,p)
If *t Is xyz2 Then Delete Cast(xyz2 Ptr,p)
If *t Is xyz3 Then Delete Cast(xyz3 Ptr,p)
If *t Is xyz4 Then Delete Cast(xyz4 Ptr,p)
If *t Is xyz5 Then Delete Cast(xyz5 Ptr,p)
If *t Is xyz6 Then Delete Cast(xyz6 Ptr,p)
If *t Is xyz7 Then Delete Cast(xyz7 Ptr,p)
If *t Is xyz8 Then Delete Cast(xyz8 Ptr,p)
If *t Is xyz9 Then Delete Cast(xyz9 Ptr,p)
If *t Is xyz10 Then Delete Cast(xyz10 Ptr,p)
If *t Is xyz11 Then Delete Cast(xyz11 Ptr,p)
If *t Is xyz12 Then Delete Cast(xyz12 Ptr,p)
If *t Is xyz13 Then Delete Cast(xyz13 Ptr,p)
If *t Is xyz14 Then Delete Cast(xyz14 Ptr,p)
If *t Is xyz15 Then Delete Cast(xyz15 Ptr,p)
If *t Is xyz16 Then Delete Cast(xyz16 Ptr,p)
End Sub
sub killstring(byref p as any ptr)
Var t=Cast(Object Ptr,p)
If *t Is xyz1 Then Cast(xyz1 Ptr,p)->name=""
If *t Is xyz2 Then Cast(xyz2 Ptr,p)->name=""
If *t Is xyz3 Then Cast(xyz3 Ptr,p)->name=""
If *t Is xyz4 Then Cast(xyz4 Ptr,p)->name=""
If *t Is xyz5 Then Cast(xyz5 Ptr,p)->name=""
If *t Is xyz6 Then Cast(xyz6 Ptr,p)->name=""
If *t Is xyz7 Then Cast(xyz7 Ptr,p)->name=""
If *t Is xyz8 Then Cast(xyz8 Ptr,p)->name=""
If *t Is xyz9 Then Cast(xyz9 Ptr,p)->name=""
If *t Is xyz10 Then Cast(xyz10 Ptr,p)->name=""
If *t Is xyz11 Then Cast(xyz11 Ptr,p)->name=""
If *t Is xyz12 Then Cast(xyz12 Ptr,p)->name=""
If *t Is xyz13 Then Cast(xyz13 Ptr,p)->name=""
If *t Is xyz14 Then Cast(xyz14 Ptr,p)->name=""
If *t Is xyz15 Then Cast(xyz15 Ptr,p)->name=""
If *t Is xyz16 Then Cast(xyz16 Ptr,p)->name=""
end sub
#define Intrange(f,l) Int(Rnd*((l+1)-(f))+(f))
Dim As Any Ptr p
Dim As Long i
Do
i=intrange(1,16)
Select Case As Const i
Case 1:p=New xyz1:Cast(xyz1 Ptr,p)->Name=pad
Case 2:p=New xyz2:Cast(xyz2 Ptr,p)->Name=pad
Case 3:p=New xyz3:Cast(xyz3 Ptr,p)->Name=pad
Case 4:p=New xyz4:Cast(xyz4 Ptr,p)->Name=pad
Case 5:p=New xyz5:Cast(xyz5 Ptr,p)->Name=pad
Case 6:p=New xyz6:Cast(xyz6 Ptr,p)->Name=pad
Case 7:p=New xyz7:Cast(xyz7 Ptr,p)->Name=pad
Case 8:p=New xyz8:Cast(xyz8 Ptr,p)->Name=pad
Case 9:p=New xyz9:Cast(xyz9 Ptr,p)->Name=pad
Case 10:p=New xyz10:Cast(xyz10 Ptr,p)->Name=pad
Case 11:p=New xyz11:Cast(xyz11 Ptr,p)->Name=pad
Case 12:p=New xyz12:Cast(xyz12 Ptr,p)->Name=pad
Case 13:p=New xyz13:Cast(xyz13 Ptr,p)->Name=pad
Case 14:p=New xyz14:Cast(xyz14 Ptr,p)->Name=pad
Case 15:p=New xyz15:Cast(xyz15 Ptr,p)->Name=pad
Case 16:p=New xyz16:Cast(xyz16 Ptr,p)->Name=pad
End Select
killstring(p) 'optionbal
destroy(p)
Sleep 1
Loop Until Inkey=Chr(27)
Sleep