Possible Fix to deal with Python Memory usage
<p>I have the following class:</p>

<pre><code> class C1:
    STORE = []
    TYPE = []
    ITEMS = []
    PRICE = []


    def __init__(self,STORE,TYPE,ITEMS,PRICE):
        self.STORE = STORE
        self.TYPE = TYPE
        self.ITEMS = ITEMS
        self.PRICE = PRICE
</code></pre>

<p>The purpose of the class is to store all the items in different stores and their prices. Items are alphanumerically ordered, and if the item doesn't exist in a store it shows the price as 0. I am retrieving the data from a table in a database that looks like this:</p>

<pre><code>           S1  S2  S3 .... S29000
item1      15   2  30 ....    100
item2       0   1   0 ....      5
.
.
.
item600     30 190 10 ....     25
</code></pre>

<p>The lists STORE and ITEMS look like the following accordingly:</p>

<p>STORE: ['S1','S2',...,'S29000'] 
ITEM: ['item1','item2',....,'item600']</p>

<p>For the PRICE list it is a multidimensional list which by specifying the store index and item index it would give you the price of the specified item at specified store (ex. price[0][0] will get you the price of item1 at S1 which is 15).</p>

<p>With all this data in a class, I run 'reports' with some 'complex' computation involved.</p>

<p>I am running into the problem that I am creating class objects from different tables and the memory usage of python reaches almost 1.8 GB according to Windows Task Manager.</p>

<p>I know that my objects are the main reason of the memory consumption, which brings me to two questions:</p>

<ol>
<li><p>I 'del' every class object after I use them and gc and it appears python doesn't want to let go of the memory even after the script is done. Is there a brute force method to free it up?</p></li>
<li><p>Are there data structures other than lists which would consume less memory and improve my performance? I noticed Numpy as being an option but I am forced to use Python 2.3 and it appears that it is not compatible with Numpy.</p></li>
</ol>

<p>I had previously tried to read the database every time that I wanted to compute something which would take my program to run for almost 3 hours, but now when storing the data into a classes it takes 40 minutes. So my 'client' doesn't want to go to the old way.</p>

<p>Thanks in advance.</p>

<p>EDIT: The original data looks like the table that I described previously, but it is only accessible through the API provided by the vendor.</p>

<p>EDIT2: My intention is to create various objects of type C1 for multiple 'data sources.' So I would end up with 6 C1 type objects containing distinct data in each one of them </p>

<p>EDIT3: In order to access the list of prices of items per store, the API has one function which is in the form of GetPrices('Store Name'). So It is necessary to call this function for every store. Therefore currently, my code that genereates C1 objects has one huge For Loop that calls this function for every Store.</p>
