Free the list's memory from heap.
Free the list's memory from heap.Note: The memory of the elements themselves is not freed.
For array lists this method has a time complexity of O(1).
For linked lists this method has a time complexity of O(N), with N being the number of elements in the list.