[squeak-dev] Another Memory Problem

Herbert König herbertkoenig at gmx.net
Wed Mar 20 19:09:00 UTC 2013


Hi,
Am 19.03.2013 07:26, schrieb Levente Uzonyi:
>
> 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.:
>
> FileStream readOnlyFileNamed: 'yourBigFile.csv' do: [ :file |
>     [ file atEnd ] whileFalse: [
>         | line |
>         line := file nextLine.
>         "process the line" ] ].
>
biggest gain is the reduction from 470 MB of peak memory to 352 MB. Time 
went down from 2:40 to 2:15 it seems most of the time is spent in 
initializing the objects. Changing more ivars to symbols brought the 
time back up to 2:25 but memory down to 227 MB.  Never thought of 
symbols as memory savers before :-)

Thanks for the tip,

Herbert
> 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.
>
>
> 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/20130320/1233f798/attachment.htm


More information about the Squeak-dev mailing list