[squeak-dev] Another Memory Problem

Herbert König herbertkoenig at gmx.net
Tue Mar 19 07:08:17 UTC 2013


Hi Levente,

Am 19.03.2013 07:26, schrieb Levente Uzonyi:
>>
>> I read the whole file into a String and before I sprinkled the method 
>> with debugging aids it looked like:
>
> That's pretty likely the cause of the problem, your image is probably 
> running out of memory. You can't use more than 512 MB on windows.
>
> You should rewrite your code to read the file line by line (it should 
> be a lot faster this way). E.g.:

I thought of this too but assumed it to be slower as I have to go to the 
OS more often. Will check and report.

I wasn't aware of the hard 512M limit on Win. The normal case would be 
1000 files of 160k each. Each file represents the production test of one 
amplifier and in this special case I tested one Amp a thousand times.


>
> FileStream readOnlyFileNamed: 'yourBigFile.csv' do: [ :file |
>     [ file atEnd ] whileFalse: [
>         | line |
>         line := file nextLine.
>         "process the line" ] ].
>
> If your file only contains ASCII characters, then you can optimize it 
> even further by using StandardFileStream instead of FileStream, which 
> will save you the time spent with encoding the characters.
>

Thanks for the tip.

Cheers

Herbert

>
> Levente
>
>>
>> initFrom: aString
>>    "read the protocol file via feeding its lines into a state machine 
>> each performed method returns the state for the next line"
>>    |status|
>>    status := #initialHeaders:.
>>    aString linesDo: [:line|
>>        status := self perform: status with: line].
>>
>> Latest Cog VM, image updated to 12333.
>>
>> Cheers,
>>
>> Herbert
>>
>>
>>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20130319/ead25cb2/attachment.htm


More information about the Squeak-dev mailing list