I'm dealing with input table-handle that needs to be deleted at the end of the procedure or method to avoid memory-leak. A copy of the temp-table is created upon procedure or method call in this case. The problem is I need to know if the caller specified the BY-REFERENCE keyword, which means I can't just run my usual clean up code. The cleanup might have to be done in the caller code.
Any ideas?
|
If this is in a persistent procedure or class you can grab the table's handle when the instance is instantiated and store that. In the API call check to see if the stored handle matches the table's current handle - if they're different, you have a by-reference call. If they're the same, it's local and the call was by-value.
Peter,
Is there a reason why implicitly (temp-table and prodataset handle) created copies by the framework can't be cleaned up automatically by the framework?
Peter, my test shows that BY-REFERENCE works nicely without REFERENCE-ONLY definitions.
It's 0 when called without BY-REFERENCE (and the caller would have to delete)
It's 1 when called with BY-REFERENCE (and the caller should usually not have to delete).
Thank you for confirming this.
[quote user="Mike Fechner"]
Peter, my test shows that BY-REFERENCE works nicely without REFERENCE-ONLY definitions.
It's 0 when called without BY-REFERENCE (and the caller would have to delete)
It's 1 when called with BY-REFERENCE (and the caller should usually not have to delete).
[/quote]
Should have been "callee", not caller in my response above.
It didn't work for me. It's always returning 0.
I'm on 11.6.
Caller: procedure (.p)
Callee: class (.cls)
[quote user="Mike Fechner"]
Peter, my test shows that BY-REFERENCE works nicely without REFERENCE-ONLY definitions.
It's 0 when called without BY-REFERENCE (and the caller would have to delete)
It's 1 when called with BY-REFERENCE (and the caller should usually not have to delete).
[/quote]