
Daniel Becroft (Partner) asked a question.
We're investigating some memory leaks, and we believe it's due to some ... misuse and misunderstanding about how the BY-REFERENCE option works. During some testing, we found that it seems to operate differently between TABLE-HANDLE and DATASET-HANDLE.
For TABLE-HANDLE, if we pass a parameter as INPUT TABLE-HANDLE BY-REFERENCE, then use DELETE OBJECT in the called procedure, the table is deleted in the caller procedure as well. This matches the same behaviour as if it was passed as a regular HANDLE.
For a DATASET-HANDLE, the caller's version is not deleted. We do need the NO-ERROR on the DELETE OBJECT to avoid error 12327 (Cannot delete a BY-REFERENCE PARAMETER dataset or table in the called procedure.) Everything we can see in the documentation indicates that there should be no difference in the behaviour between the two different object types , and the error message for 12327 refers to "table" as well, indicating that it should be applicable there).
The example code for both scenarios is here (we've tried both internal and external procedure calls, with the same result). For the table-handle, we get "yes", then "no" (indicating the table has been deleted from the internal procedure). For the dataset-handle, we get "yes" both times (so the internal procedure does not delete that object).
- define variable vTableHandle as handle no-undo.
-
- procedure InternalProcedure:
-
- define input parameter table-handle vInternalTableHandle.
-
- delete object vInternalTableHandle.
- vInternalTableHandle = ?.
-
- end procedure.
-
- create temp-table vTableHandle.
-
- vTableHandle:add-new-field("Field01", "CHARACTER").
-
- vTableHandle:temp-table-prepare("ttTable").
-
- run InternalProcedure(input table-handle vTableHandle).
-
- message valid-handle(vTableHandle) view-as alert-box.
-
- run InternalProcedure(input table-handle vTableHandle by-reference).
-
- message valid-handle(vTableHandle) view-as alert-box.
- define variable vTableHandle as handle no-undo.
- define variable vDatasetHandle as handle no-undo.
-
- procedure InternalProcedure:
-
- define input parameter dataset-handle vInternalDatasetHandle.
-
- delete object vInternalDatasetHandle no-error.
- vInternalDatasetHandle = ?.
-
- end procedure.
-
- create temp-table vTableHandle.
-
- vTableHandle:add-new-field("Field01", "CHARACTER").
-
- vTableHandle:temp-table-prepare("ttTable").
-
- create dataset vDatasetHandle.
- vDatasetHandle:add-buffer(vTableHandle:default-buffer-handle).
-
- run InternalProcedure(input dataset-handle vDatasetHandle).
-
- message valid-handle(vDatasetHandle) view-as alert-box.
-
- run InternalProcedure(input dataset-handle vDatasetHandle by-reference).
-
- message valid-handle(vDatasetHandle) view-as alert-box.
@Daniel Becroft (Partner) There is already an existing defect on this issue which is not fixed yet. However, the reported behaviour requires further investigation and to get more information on the defect status. If you haven't done so already, please consider creating a ticket
with Technical Support @ Support Link landing Page
Thanks @Sai Pasupuleti (Progress Software) , I've raised a support case.