Greetings. I'm very excited about all the knowledge you all have help me to get this past days... I thank you all.
One of the things I'm getting grasp on, is the .Net objects... And this first class I have, i've being refining more and more. Now came to this..
In order of to keep this program running long, should I have to dispose the vars I define as System.Byte[], between calls to the methods that use some iterations of those vars? This is: If I've done with a var in some point, should i:
systemByteVar1 = ?.
Or I can think of them being collected as some native datatype var?
Tanks that it's clear and noticed,
but my question goes more in this use-case:
on ABL, a class is instantiated with a Byte[] defined as global to the class, then a method inside is called. This method happens to use that Byte[], does stuff on it, included, it is sended to a method that does this on it:
METHOD PRIVATE STATIC MEMPTR ByteArrayToMemptr (poBytes AS "System.Byte[]":U): DEFINE VARIABLE myMemptr AS MEMPTR NO-UNDO . DEFINE VARIABLE oIntPointer AS System.IntPtr NO-UNDO . SET-SIZE (myMemptr) = poBytes:Length . oIntPointer = NEW System.IntPtr (GET-POINTER-VALUE (myMemptr)). System.Runtime.InteropServices.Marshal:Copy (poBytes, 0, oIntPointer, poBytes:Length). RETURN myMemptr. FINALLY: DELETE OBJECT oIntPointer. END FINALLY. END METHOD .
and the System.IntPtr should be explicity DELETEd inside the method.
Then at return, the Byte[] in question it is handled and the method returns control to UIB ABL...
My question is, that Byte[], for the next iteration/use of the method, should be emptyr'd first? (or otherwise, at return from former method, asigned to ?)...
Well,, infact I missed to elaborate more on this situation, and perhaps that shows why is my dubitation...
Inside those methods on this class. it is performed this, as a reverting process to the anterior posted manipulation:
METHOD PRIVATE STATIC "System.Byte[]" MemptrToByteArray( pmptr AS MEMPTR ): DEFINE VARIABLE nPtr AS System.IntPtr NO-UNDO. DEFINE VARIABLE vInt AS INTEGER NO-UNDO. DEFINE VARIABLE nBytes AS "System.Byte[]". vInt = GET-SIZE(pmPtr). nBytes = NEW "System.Byte[]"(vInt). nPtr = NEW System.IntPtr(GET-POINTER-VALUE(pmPtr)). System.Runtime.InteropServices.Marshal:Copy(nPtr, nBytes, 0, vInt). RETURN nBytes. FINALLY: nPtr = ?. set-size(pmPtr) = 0. nBytes = ?. END. END METHOD. // - See more at: community.progress.com/.../100235
Notice the explicit SET-SIZE(pmPtr).
That's why I have doubt about the System.Byte[] needed some special handling after use...
Thanks... I'll do as told....