Hi,
I'm working on a scheme to store several millions of records (Subdata),
each of which contains a variable number of sub records (Celldata). My concern is that
my prototype uses a lot more memory than I'm expecting. To store 1.7million Subdatas
that have an average of 7 Celldatas, I'm using 85 Mb. Thats about 50 bytes/record, where as
actual data is about 14 bytes/record (average).
Any insight is greatly appreciated!
Ken
Cliffnoted code is as follows:
class Celldata
{
public:
short cellnum:10,
time_stamp:6;
Celldata(int, int);
};
class Subdata
{
public:
vector<Celldata> cells;
int add_cell(int cell, int time);
};
class Esn_global
{
public:
vector<Subdata> sublists;
}
int
Subdata::add_cell( int cell, int time)
{
Celldata newcell(cell, time);
cells.push_back(newcell);
return 1;
}
Esn_global g_esn;
main()
{
for (loop forever)
{
-read record containing subscriber identifier and cell
- add cell to subcribers list (if not already on list)
}
}
I've trimmed some of the code out, there is another structure that takes a subscriber's
identifier (phone number) and returns an index into g_esn.sublists that corresponds to that users
data.
I'm wondering if I should be making new class instances with a 'new' and then pushing onto my
vectors?
I've also played around with resizing the vectors by 2 entries when they are full to prevent them from
doubling in size when they fill; this didn't seem to be a benefit....
I was pushing all the instances onto vectors to avoid any memory leaking and also thought it would be better
for daily audits of the data. Maybe this is my problem?
thanks