title: Debugging Access Violation errors?
body: <p>What tips can you share to help locate and fix access violations when writing applications in Delphi?</p>
  
  <p>I believe access violations are usually caused by trying to access something in memory that has not yet been created such as an Object etc?</p>
  
  <p>I find it hard to identify what triggers the access violations and then where to make the required changes to try and stop/fix them.</p>
  
  <p>A example is a personal project I am working on now. I am storing in TTreeView Node.Data property some data for each node. Nodes can be multiple selected and exported (the export iterates through each selected node and saves specific data to a text file - the information saved to the text file is what is stored in the nodes.data). Files can also be imported into the Treeview (saving the contents of the text files into the node.data).</p>
  
  <p>The issue in that example is if I import files into the Treeview and then export them, it works perfect. However if I add a node at runtime and export them I get:</p>
  
  <blockquote>
    <p>"Access Violation at address 00405772 in module 'Project1.exe'. Read of address 00000388."</p>
  </blockquote>
  
  <p>My thoughts on that must be the way I am assigning the data to created nodes, maybe differently to the way I assign it when they are imported, but it all looks ok to me. The access violation only shows up when exporting, and this never happens with imported files.</p>
  
  <p>I am NOT looking for a fix to the above example, but mainly advice/tips how to find and fix such type of errors. I don't often get access violations, but when I do they are really hard to track down and fix.</p>
  
  <p>So advice and tips would be very useful.</p>