S
simon
Hi,
First some background.
I have a structure,
struct sFileData
{
char*sSomeString1;
char*sSomeString2;
int iSomeNum1;
int iSomeNum2;
sFileData(){...};
~sFileData(){...};
sFileData(const sFileData&){...};
const sFileData operator=( const sFileData &s ){...}
};
std::vector< sFileData, std::allocator<sFileData>> address_;
for the sake of simplicity I remove the body of the 'tors
I have no memory leaks as far as I can tell.
Then I read a file, (each line is 190 chars mostly blank spaces).
In each line I 'read' info to fill in the structure.
Because there are some many blank spaces in the line I make sure that my
data is 'trimmed'.
So in effect sSomeString1 and sSomeString2 are never more than 10 chars,
(although in the file they could be up to 40 chars).
I chose vectors because after reading the file I need to do searches of
sSomeString1 and sSomeString2, (no other reasons really).
But my problem is the size of address_ is not consistent with the size of
the file.
The file is around 13Mb with around 100000 'lines' of 190 chars each.
Because I remove blank spaces and I convert 2 numbers to int, (from char). I
guess I should not use more than half, 5Mb.
But after loading I see that I used around 40Mb, (3 times more than the
original size).
as far as I can tell you cannot really tell the size of a vector, but I use
windows and the task manager and I can see the size of my app before and
after reading the file, (I do nothing else).
So what could be the reason for those inconsistencies?
How could I optimize my code to compress those 40mb even more?
Many thanks
Simon
First some background.
I have a structure,
struct sFileData
{
char*sSomeString1;
char*sSomeString2;
int iSomeNum1;
int iSomeNum2;
sFileData(){...};
~sFileData(){...};
sFileData(const sFileData&){...};
const sFileData operator=( const sFileData &s ){...}
};
std::vector< sFileData, std::allocator<sFileData>> address_;
for the sake of simplicity I remove the body of the 'tors
I have no memory leaks as far as I can tell.
Then I read a file, (each line is 190 chars mostly blank spaces).
In each line I 'read' info to fill in the structure.
Because there are some many blank spaces in the line I make sure that my
data is 'trimmed'.
So in effect sSomeString1 and sSomeString2 are never more than 10 chars,
(although in the file they could be up to 40 chars).
I chose vectors because after reading the file I need to do searches of
sSomeString1 and sSomeString2, (no other reasons really).
But my problem is the size of address_ is not consistent with the size of
the file.
The file is around 13Mb with around 100000 'lines' of 190 chars each.
Because I remove blank spaces and I convert 2 numbers to int, (from char). I
guess I should not use more than half, 5Mb.
But after loading I see that I used around 40Mb, (3 times more than the
original size).
as far as I can tell you cannot really tell the size of a vector, but I use
windows and the task manager and I can see the size of my app before and
after reading the file, (I do nothing else).
So what could be the reason for those inconsistencies?
How could I optimize my code to compress those 40mb even more?
Many thanks
Simon