8. Sep 2011


Tidy up when done

These days in the 4D_Tech mailing list:

do you clear local variables after you're done with them?

I have to process close to a million records. The process is a method that creates big local variables. Big arrays, big text vars. But it's a sub-call, so after each call the locals will get cleared auto-magically.

I'm semi-superstitious and am thinking I should clear them myself at the end of the sub-method.

Silly? Paranoid? No harm? Great idea?

Good question, isn't it?

I'm trough with that! Why, because it's easy now. All I need to do is call Gen_EmptyContent and send all those Vars and fields which need to be emptied like this:
Gen_EmptyContent (->multiValues_L;->$abCompany;->$abFName;->$abLName;->$a_Notiz_T;->abTitel;->concatName;->messageText;->abUUID;->abPicture;->abGeboren_D)

This clears a bunch of variables, takes care about types and even tries not to invoke 4Ds error-handling like here
: ($type=Is BLOB)
  If (BLOB size($currObject->)>0) // throughs an error when already empty
    SET BLOB SIZE($currObject->;0)
  End if

Download the zipped text of the method


ja, si, oui, はい