The following simple code copies some cells into the clipboard and gets it back as text data. Later this data will be POSTed to an internal webservice, but this is commented out at this point of time. Every time I run the script the used memory of the Excel grows by about 80MB (twice the size of the string). I have no clue where/why the garbage collector fails and what I can do againt this.
Sub memory_leak()
Dim DataObj As New MSForms.DataObject
Dim data As String
'Copy Data Range ~ the first 250.000 rows / 22 columns
Range(Cells(9, 1), Cells(250000, 22)).Copy
DataObj.GetFromClipboard
data = DataObj.GetText
' Call postToURL("http://intranet/API.php?action=test", data)
'Try to free memory...
Application.CutCopyMode = False
DataObj.Clear
data = ""
End Sub