Home Segments Index Top Previous Next

640: Mainline

At this point, your new program is complete, and works fine, but if you run it long enough, it will fill up your computer's memory with useless class objects. To see why, note that, once one file—one that contains, say, three cars—has been analyzed, the memory involved in the analysis looks as follows:

             0                   1                   2     <-- train 
             |                   |                   |         array 
             v                   v                   v         index 
     ------------------- ------------------- ------------------- 
----*-------------------*-------------------*-------------------*--- 
    |  First pointer    |  Second pointer   |  Third pointer    | 
 ---*-------------------*-------------------*-------------------*----  
             |                   |                   | 
             v                   v                   v 
     *-----------------* *-----------------* *-----------------* 
     | First allocated | | Second allocated| | Third allocated | 
     | chunk of memory | | chunk of memory | | chunk of memory | 
     *-----------------* *-----------------* *-----------------*