Forum > General

TFPGList.Put mem leak?

(1/1)

AlexTP:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFPGList.Put(Index: Integer; const Item: T);begin  inherited Put(Index, @Item);end;  
Do we miss Deref call here for the Item content before overwriting the Item?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFPGList.Deref(Item: Pointer);begin Finalize(T(Item^));end;       

Bart:
I would argue that it is the responsibility of the programmer to clean up the item before overwriting itwith a new one.
And I wonder wether you can call Finalize() on any type.

Bart

marcov:
If TFPGList is the generic version of  TFPList, that is expected.

FPList saves on events relative to TList, but those events are also used to managed automated types.

Arioch:

--- Quote from: Bart on September 09, 2022, 11:30:37 am ---I would argue that it is the responsibility of the programmer to clean up the item before overwriting itwith a new one.
And I wonder wether you can call Finalize() on any type.

--- End quote ---

Would it be so, then DeRef method should had been removed outright and the list should had do no finalization at all.

But if there is such a method, and if the lsit can do finalizations - they have to be consistent indeed;

P.S. i woud also check `TFPList.Extract` implementation then...

Navigation

[0] Message Index

Go to full version