I'm trying to read a flat file, load data onto a structure and then insert the structured data into the std::multimap.
The problem is that the input data file is a very large file.. about 30gig in size.
I'm iterating through this file line-by-line but I'm only been able to read the first 10,000,000 lines before the program aborts!
Any assistance to overcome this problem would be highly appreciated.
output:
Record count is: 1000000
Record count is: 2000000
Record count is: 3000000
Record count is: 4000000
.
.
.
Record count is: 63000000
Record count is: 64000000
Record count is: 65000000
Record count is: 66000000
Aborted
By the way, I'm compiling and running this program on a 32 bit linux box
I would guess that you probably do not always need all of those char's allocated to store your values; why not parse the record, and store the fields in STL strings? Depending on your data, this should save some memory usage.
I'm thinking probably process() based of the key. That is, only insert records that shares the same key to the map at a time.
BTW, this map (produced by the process routine) is further manipulated and the entire manipulation is determined from the key
On a 32-bit system the maximum theoretical amount of addressable memory available to a program is 4GB. Trying to load 30GB? Nope, never, regardless of how much swap you have.
What about inserting into multiple multimaps and then merge them?
What about it?
How can I deallocate the memory for instance from the myMap in the code above?
myMap.clear()? Although you'll first have to iterate the map (with an iterator) to free each value.
By the way, I just took a better look at your code, and it sucks:
By the way, I just took a better look at your code, and it sucks:
Thanks for critique'ing my code ;-)
It was just something that I had put together in hurry as I assimilate the requirements
Also, it tell you I'm not the best of the coder in the world, one of the reasons I'm here seeking guidance and assistance from some good people like yourself.
If you have a minute, you can have another look at it... I updated and improved a little.