in reply to Re^2: segmentation fault (core dumped!)
in thread segmentation fault (core dumped!)
The code, as you have it, is reading the entire "2.txt" file into memory, and then making another copy of it in memory as it's converted from an array to a scalar. So your memory footprint is a lot bigger than it has to be. But depending on your system, it may not help to simply avoid making that second copy. You may need to come up with an algorithm that doesn't pull the entire 3gb file into memory all at once.
Here are three distinct alternatives that you might consider:
There are surely other strategies, but these are at least options you can consider.
Each of these has implications with respect to complexity and performance. You know more about your problem than we do, and frankly, I'm not too interested in implementing a seek/tell or transcoding solution for you. But both are possible (albeit a pain in the backside).
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: segmentation fault (core dumped!)
by Anonymous Monk on Jul 03, 2012 at 06:36 UTC | |
|
Re^4: segmentation fault (core dumped!)
by Anonymous Monk on Jul 03, 2012 at 06:19 UTC | |
by davido (Cardinal) on Jul 03, 2012 at 08:24 UTC | |
by marto (Cardinal) on Jul 03, 2012 at 08:41 UTC |