It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Simple app, strange memory leak?

Moderator: dafunkymunky

Simple app, strange memory leak?

Postby Psycho0124 on Fri Jun 17, 2011 5:06 pm

I'm a bit of a noob at this; this is my first VB application and I only started learning last night so bear with me. :oops:

The app is meant to calculate markups and taxes for resale.
I've ironed all the kinks out and the app works perfectly except for an odd memory issue.
I added an option to automatically grab and calculate data from the windows clipboard (so I can Ctrl+C stuff from other programs) and managed to get it to filter out everything but text data copied in there.
It limits the length of text it will input into the calculator but for some reason it causes the memory usage to climb until crash while a large block of text resides in the clipboard and Check2 is enabled (I attached the little app here if you want to see the behavior. Just copy a large document, check Auto-Fill and watch the memory usage climbing).

Here's the code that seems to be the culprit:
Code: Select all
Private Sub Timer1_Timer()
'auto-fill from clipboard'
If Check2.Value = 1 Then
    Dim DataObj As New MSForms.DataObject
        DataObj.GetFromClipboard
            'It's text right? It's not too long is it?"
            If (Clipboard.GetFormat(vbCFText) = True) And ((Len(DataObj.GetText()) < 10)) Then
            'okay, it's good, fill Text1 with the data'
            Text1.Text = DataObj.GetText
            Else
            'memory use climbs continually with large areas of text in clipboard. Solution?'
            DataObj.Clear
            Set DataObj = Nothing
            End If
    End If
'kill it again!!'
DataObj.Clear
Set DataObj = Nothing
End Sub


Anybody know what I'm doing wrong? I can be careful running the app so it still works okay but I'd like to learn to do it correctly.
Thanks for any help you could give me!
-John
You do not have the required permissions to view the files attached to this post.
Psycho0124
 
Posts: 1
Joined: Fri Jun 17, 2011 4:47 pm

Who is online

Users browsing this forum: No registered users and 5 guests