[SOLVED] Are dynamic arrays automatically freed? lazarus / 61-Beginners ---------------------------------------------------------------------- Eugene Loza · 2016-12-13 08:12 Are dynamic arrays automatically freed? E.g. I create an object Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Type TObj = class(TObject)MyArray: Array of byte;constructor create;end; var TheObject: TObj; constructor TObj.create;begin  setlength(MyArray,100);end; Should I create a destructor with Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i destructor TObj.destroy;begin  MyArray := nil; //this should free the array according to the documentationend;Or is it done automatically on freeannil(TheObject)? ---------------------------------------------------------------------- howardpc · 2016-12-13 08:44 It is done automatically by compiler-inserted code when the dynamic array goes out of scope. Belt and braces approach would do a   SetLength(MyArray, 0); but it only duplicates what the compiler does for you anyway. ---------------------------------------------------------------------- Eugene Loza · 2016-12-13 08:50 Thanks a lot!