Results 1 to 8 of 8

Thread: Memory Leak in Mdi Form

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Posts
    4

    Memory Leak in Mdi Form

    I am having issues with memory still being allocated when opening a form from an mdi when the form is closed.

    I have attempted to change the mdi code when the form is called, using set formname = nothing.

    This does not appear to be clearing up form, and it's memory. When the form is unloaded the session is cleared. After all objects are cleared they also set to nothing.

    I am using VB6 and an sql database.

    Any ideas????

  2. #2
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    carawheeler

    Need more info on your situation. Possibly some code?

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Posts
    4
    Private Sub mnuCreateTicket_Click()
    Screen.MousePointer = vbHourglass
    Load frmSearchForPNR
    Screen.MousePointer = vbNormal
    frmSearchForPNR.Show
    Set frmSearchForPNR = Nothing
    End Sub

    '/////////////////////////////////////////////////////////////////////////////////////////////
    '// NAME : frmSearchForPNR
    '// PURPOSE : frmSearchForPNR is displayed to give the user the ability to select a PNR
    '// that is ready to be ticketed
    '//
    '/////////////////////////////////////////////////////////////////////////////////////////////
    Option Explicit

    Private Const C_CLR As String = ""
    Private Const C_DATE_FORMAT As String = "dd/mm/yyyy HH:MM AM/PM"
    Private Const C_PNR_ID As String = "PNR ID="
    Private Const C_PARM_PNR_ID As String = "PNRID"
    Private Const C_PARM_PNR_TICKETER_ID As String = "TicketerID"
    Private Const C_PARM_PNR_NOTES As String = "Notes"
    Private Const C_TICKETERS As String = "Ticketers"
    Private Const C_TKT_ID As String = "TKTer ID= "
    Private Const C_CURRENT_PNR As String = "Current PNR: "
    Private Const C_LAST_MODIFIED_KEY As String = "Last Modified="
    Private Const C_PNR_VERSION_SEPARATOR As String = "/"
    Private Const C_IMAGE_OPEN As String = "open"
    Private Const C_IMAGE_CLOSE As String = "close"

    '// Constants Error Messages
    Private Const C_ERR_MSG_CONTACT_SYSAMINISTRATOR As String = "Please contact System Administration"

    Dim ndeFOUNDPNR As Node
    Dim ndeCancelPNR As Node
    Dim ndePNR As Node
    Dim ndeSelectedPNR As Node
    Dim blnNewPNR As Boolean

    Private m_objsession As oasisdbcnn.cSession

    Private Sub Form_Load()
    '////////////////////////////////////////////////////////////////////////////////////////////////////////
    '// Sub : Form_Load
    '// Purpose : Loads the form and populates the controls with data that is issued in this sub.
    '//
    '////////////////////////////////////////////////////////////////////////////////////////////////////////
    On Error GoTo errhandler

    Const C_PNRID As String = "PNRID = "

    Set m_objsession = New oasisdbcnn.cSession
    Call m_objsession.Init(gobjSc, osmReadWrite)

    '// clear text boxes ready for input from user
    txtPNRDetails.text = C_CLR
    txtSearchForPartialPNR.text = C_CLR

    '// call to setup the listview column headers
    Call createHeaders

    '// call to load the listview control with new pnrs
    Call DisplayAllPNRS

    '// load treeview control with partially complete pnrs
    Call DisplayPartialPNRS

    '// check for if no items are populated on the listview control, if so we can at least create a ticket
    If Me.lstviwPNR.ListItems.Count > 0 Then
    Set gobjPNR = gobjPNRS.Search(Mid(Me.lstviwPNR.SelectedItem.Key, Len(C_PNRID) + 1))
    txtPNRDetails.text = CrsText(gobjPNR.PNRText)
    Me.cmdCreateTicket.Enabled = True
    Else
    '// can't create a ticket as no new pnrs are retrieved from the database
    Me.cmdCreateTicket.Enabled = False
    End If

    Me.tvwPNR.Nodes.Item(1).Expanded = True

    Exit Sub
    errhandler:
    If Err.Number > vbObjectError Then
    Call DisplayError(Err.Number - vbObjectError, Err.Description, Err.source)
    Else
    Call DisplayError(Err.Number, Err.Description, "frmSearchForPNR")
    End If
    End Sub

    Private Sub cmdCancel_Click()
    '/////////////////////////////////////////////////////////////////////////////////////
    '// SUB : cmdCancel_Click
    '// PURPOSE : Unloads the form
    '////////////////////////////////////////////////////////////////////////////////////
    Unload Me

    End Sub

    Private Sub Form_Unload(Cancel As Integer)

    If (Not m_objsession Is Nothing) Then
    m_objsession.DeInit
    Set m_objsession = Nothing
    End If

    End Sub

  4. #4
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    carawheeler,

    From the code you posted... I do not see a few things.


    1 - Is frmSearchForPNR unloaded or just flashes on the screen.
    2 - I see no database connection/recordset open, close or set to nothing (is this happening somewhere else).

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Posts
    4
    The form gets loaded. The connections are loaded and cleaned up in other classes.

    Here is some of the search code. (This form is huge so I can't put all the code up)

    Private Sub cmdSearch_Click()
    '/////////////////////////////////////////////////////////////////////////////////////
    '// SUB : cmdSearch_Click
    '// PURPOSE : Launches code to search on the PNR number that the user has entered
    '// and retrieve PNR and to call function LoadDataIntoListViwPNRControl(recPNR)
    '// INPUTS : NONE
    '// OUTPUTS : NONE
    '////////////////////////////////////////////////////////////////////////////////////
    On Error GoTo PROC_ERR
    Const PROCEDURE_NAME = "cmdSearch_Click"

    Const C_NO_PNRS_FOUND As String = "There are no PNR's that meet your match!"
    Const C_NO_PNR As String = ""

    Screen.MousePointer = vbNormal

    If txtRelocNumber.text = C_NO_PNR Then
    MsgBox "Please enter a PNR/Reloc Number", vbOKOnly + vbInformation, "Missing PNR/Reloc Number"
    Exit Sub
    End If

    Screen.MousePointer = vbHourglass
    If lstviwPNR.ListItems.Count > 0 Then
    lstviwPNR.ListItems.Clear
    End If

    Dim cmdSearchForPnr As OasisDBCnn.cStoredProcedure
    Set cmdSearchForPnr = m_objSession.StoredProcedures("OASISqrySearchForPNR")
    Dim recPNR As ADODB.Recordset
    With cmdSearchForPnr
    .Parameters("RelocNo") = Me.txtRelocNumber.text
    Set recPNR = .Execute
    End With

    gblnSearch = True
    Call LoadDataIntoListViewPNRControl(recPNR)

    If recPNR.BOF = True And recPNR.EOF = True Then

    Screen.MousePointer = vbNormal

    MsgBox C_NO_PNRS_FOUND, vbExclamation + vbOKOnly, "Oasis"

    If lstviwPNR.ListItems.Count > 0 Then
    lstviwPNR.ListItems.Clear
    End If
    If tvwPNR.Nodes.Count > 0 Then
    tvwPNR.Nodes.Clear
    End If

    Call DisplayAllPNRS

    txtRelocNumber.SelStart = 0
    txtRelocNumber.SelLength = Len(txtRelocNumber.text)
    txtRelocNumber.Refresh
    txtRelocNumber.SetFocus
    Exit Sub
    Else
    cmdCreateTicket.Enabled = True
    End If
    recPNR.Close


    gblnSearch = False

    Screen.MousePointer = vbNormal

    PROC_EXIT:
    On Error Resume Next
    Set recPNR = Nothing
    Set cmdSearchForPnr = Nothing
    Exit Sub
    PROC_ERR:
    Call New_Error_Handler(MODULE_NAME, PROCEDURE_NAME, Err.Number, Err.Description)
    Resume PROC_EXIT
    End Sub

  6. #6
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    carawheeler,

    However you can upload a zip file. Also use vbcode tags when posting code.

  7. #7

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Posts
    4
    I can't give you all the classes, but I have added all the code for the form.

    Any help will be appreciated. Thanks.
    Attached Files Attached Files

  8. #8
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    VB Code:
    1. Private Sub mnuCreateTicket_Click()
    2.    Screen.MousePointer = vbHourglass
    3.    Load frmSearchForPNR
    4.    Screen.MousePointer = vbNormal
    5.    frmSearchForPNR.Show
    6.    Set frmSearchForPNR = Nothing 'This line of code will never work
    7. End Sub
    try:
    VB Code:
    1. Private Sub mnuCreateTicket_Click()
    2. Dim frmNew   As frmSearchForPNR
    3.    Screen.MousePointer = vbHourglass
    4.    Set frmNew = New frmSearchForPNR
    5.    Load frmNew
    6.    frmNew.Show
    7.    Set frmNew = Nothing
    8.    Screen.MousePointer = vbNormal
    9. End Sub
    Woka

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