I got confused by a very strange problem with a large application. I actively use TObjectList to store a custom object on them. On large lists, I experience strange crashes with "Access violation by address .. read address .." "privileged indication" and others when I use the CLEAR method. I made sure that this happens exactly when I try to delete the last item in the list. I checked this by registering the removal of the contained objects from their destroy proc, and also tried to delete them myself (for a: = olist.count-1 downto 0 do .. debugmsg ('deleting' + inttostr (a)) .. olist.delete (a)), in both cases I get an access violation when deleting the last remaining item in the list.
This is not always because I use clear in other areas, as well as several different (smaller) lists, but this happens at a very specific point in my application.
I donβt know what could be wrong, there is nothing trying to access the list during cleaning, and cointained objects do not have access to their parent list of objects in the TObjectList.delete / clear methods when it comes to clearing the last item.
Any suggestions? Using Delphi XE.
hikari
source share