Home Segments Index Top Previous Next

567: Mainline

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

              0                   1                   2    <-- Trades 
              |                   |                   |        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 | 
     *-----------------* *-----------------* *-----------------*