Results 1 to 3 of 3

Thread: [RESOLVED] VB6: memory leak question

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2007
    Posts
    22

    [RESOLVED] VB6: memory leak question

    I have a routine in a module that accepts an array as a parameter and was wondering if the way I have it coded will cause memory leaks? As a side question, does VB have a way to tell if dynamic memory is being recovered?

    Thanks in advance.

    the definition
    Code:
    Public Sub dbExist(matches() As String, arrSize As Integer)
    
       Dim spath As String, fname As String   
       Dim idx As Integer: idx = 0
       
       spath = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\")
       fname = Dir(spath, vbDirectory)
       
       While fname <> ""
          If fname <> "." And fname <> ".." Then
             If (GetAttr(spath & fname) And vbDirectory) <> vbDirectory Then
                If Right(LCase(fname), 3) = '".mdb" Then
                   ReDim Preserve matches(idx + 1)
                   matches(idx) = fname
                   idx = idx + 1
                End If
             End If
          End If
          fname = Dir
       Wend
       
       arrSize = idx
    End Sub
    The caller
    Code:
    Private Sub Form_Load()
    
       Dim dbs() As String
       Dim dsize As Integer
    
       dbExist dbs, dsize
       If dsize > 0 Then
          dbFiles.Text = dbs(0)
          For i = 0 To dsize - 1
             dbFiles.AddItem dbs(i)
          Next i
          Erase dbs
       End If
    End Sub
    Last edited by nj2b; Jan 27th, 2009 at 12:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width