I have a .tcl leak

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf I have a .tcl leak

  • Creator
    Topic
  • #52130
    Ian Morris
    Participant

      I have a proc with a tcl leak.  I believe it has a leak because when I shut the process down I get this message:

      Code:


      prod:prod:INFO/0:Med_Lab_xlate:11/29/2010 13:14:02] Checking for leaked handles in the Xlate interpreter…
      Handle     Allocated by
      ======     ============
      datum0     filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      datum1     filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      datum2     filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      datum3     filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      (And so on)

      grm0       filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      grm1       filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      grm2       filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      grm3       filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      grm4       filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      grm5       filter_LAB_INTEHEALTH {MSGID message0} {CONTEXT xlt_pre} {ARGS {}} {MODE run} {VERSION 3.0}
      (And so on)

      Here is my proc:

      Code:


      ######################################################################
      # Name:      filter_LAB_INTEHEALTH
      # Purpose:   Filter Lab messages sent to Intehealth
      #            Meditech location mnemonic CHBG
      # UPoC type: tps
      # Args:      tps keyedlist containing the following keys:
      #            MODE    run mode (”start”, “run” or “time”)
      #            MSGID   message handle
      #            ARGS    user-supplied arguments: (none)
      #
      # Returns:   tps disposition list:
      #            CONTINUE         Command to continue the route processing
      #            KILL             Command to drop further route processing
      #
      # Change Log: 03/03/2010 Created by Ian Morris
      #              Filtering confidential data on employee exposures.
      #              Filter criteria include “HELMJE” as the doctor and a blank Medical Record Number
      #
      ######################################################################
      proc filter_LAB_INTEHEALTH { args } {
         keylget args MODE mode  ;# Extract the operation mode from the run params
         set dispList {}         ;# Initialize the proc result list

         switch -exact — $mode {
             start {
             }

             run {
               # Extract the HL7 message “handle”
               keylget args MSGID mh

               # Derive the message type
               set HL7Msg   [msgget $mh]
               set FldSep   [cindex $HL7Msg 3]
               set SubSep   [cindex $HL7Msg 4]
               set SegList  [split $HL7Msg “/r”]
       
               set MSHSeg   [lindex $SegList 0]
               set FldList  [split $MSHSeg $FldSep]
               set MsgType  [lindex $FldList 8]
               set MsgType  [translit $SubSep “_” $MsgType]

              # Derive the patient’s location from the message
                set datList  [datlist] ;# Preserve the datum handle list
                set grmId    [grmcreate -msg $mh hl7 2.3 meditech $MsgType]

              set grmData1  [grmfetch $grmId {0(0).PV1.00137(0).[0]}]
      set grmData2  [grmfetch $grmId {0(0).PID.00108(0).[1]}]
      set grmData3  [grmfetch $grmId {0(0).PID.00108(0).[0]}]
                     set grmData4  [grmfetch $grmId {0(0).PID.00106(0).[0]}]

      set Doctor [datget $grmData1 VALUE]
                set FirstName [datget $grmData2 VALUE]
      set LastName [datget $grmData3 VALUE]
                     set MedicalRecordNumber [datget $grmData4 VALUE]

      #Get now
      set now [clock format [clock scan now] -format %s]
      set nowTimestamp [clock format [clock scan now]]

      # Set the filter to allow only
      echo Doctor is $Doctor
      set len [string length $MedicalRecordNumber]
      echo MedicalRecordNumber is $MedicalRecordNumber
      echo MedicalRecordNumber Length is $len
               

               if {$Doctor ne “HELMJE” && $len > 0} {
                  echo “filter_LAB_INTEHEALTH message continued for $FirstName $LastName at $nowTimestamp”
                            return  “{CONTINUE $mh}”
               } else {
      echo “filter_LAB_INTEHEALTH Killed message for $FirstName $LastName because ‘Doctor’ = $Doctor AND Medical Record Number length of $len has to be greater than 0 for the message to pass at $nowTimestamp.”
                            return  “{KILL $mh}”
               }

               # Clear memory resources
               grmdestroy $grmId
               hcidatlistreset $datList

               #Set the filtering result
               lappend dispList $Results
             }

             time {
             }
             
             shutdown {
             }

             default {
               error “Unknown mode ‘$mode’ passed to filter_LAB_INTEHEALTH”
             }
         }

         return $dispList
      }

      Can you please advise me on what I need to do to fix the leak?  I thought that doing this (see below) would close the resources and prevent the leak, but it doesn’t.

      Code:


               # Clear memory resources
               grmdestroy $grmId
               hcidatlistreset $datList

    Viewing 3 reply threads
    • Author
      Replies
      • #73181
        David Barr
        Participant

          I think if you change ‘return  “{CONTINUE $mh}”‘ to ‘set Results “{CONTINUE $mh}”‘ and do the same thing for the KILL disposition, it will fix the problem.  As it is now, you are returning from the proc before you are clearing your resources.

        • #73182
          Ian Morris
          Participant

            I changed it from this:

            Code:


            return  “{CONTINUE $mh}”

            to this:

            Code:


            set Results “CONTINUE $mh”

            Any my problem appears to be resolved.  Thank you for your help.

            [/code]

          • #73183
            Michael Lacriola
            Participant

              I can’t post what I want to say, it’s to easy…

              Becuase we need to have more humor in our lives and not take things so serioulsy…

            • #73184
              Dave Thall
              Participant

                Michael Lacriola wrote:

                I can’t post what I want to say, it’s to easy…

                Becuase we need to have more humor in our lives and not take things so serioulsy…

                If your over 50 I think theres a pill for that     8)

            Viewing 3 reply threads
            • The forum ‘Cloverleaf’ is closed to new topics and replies.