Memory Problem

Hello,
I'm a programmer and I'm writing macros for CoreldrawX4. I get a problem with it. When I import a file and making some process on it and close it again, RAM usage of X4 will full forexample 100mb and It don't clean ram memory after closing. If I run a macro that imports hundreds of files and process and close them, after 5 or 10 files processed and closed the memory usage of X4 be 4gb and then full of RAM. Shortly It doesn't clean the RAM that x4 uses for last files. It's getting huge amounts of RAM. So how can I solve this problem?

I'm giving two example of my macros that I saw full RAM usage below
Sub macro1()
   
    Dim strFileName As String
        strFileName = "C:\kofte.cdr"
    For i = 1 To 10000
       
        ActiveLayer.Import strFileName
        ActiveSelection.Delete
   
    Next

End Sub
Sub macro2()
   
    Dim strFileName As String
        strFileName = "C:\kofte.cdr"
   
    Application.Optimization = True
    Application.EventsEnabled = False
   
    For i = 1 To 10000
       
        ActiveLayer.Import strFileName
        ActiveSelection.Delete
   
    Next
    Application.Optimization = False
    Application.EventsEnabled = True
 
End Sub
 
Thanks...