[squeak-dev] Another Memory Problem

Levente Uzonyi leves at elte.hu
Tue Mar 19 06:26:08 UTC 2013


On Mon, 18 Mar 2013, Herbert König wrote:

> Hi,
>
> I'm no expert in crashing the VM so maybe it's me doing something stupid.
> I have a 157 MB semicolon delimited file from which I basically want to 
> create 1.5 million objects.
> Around 1.37 million I get the attached crash dump. Memory is around 530M
> Everything works fine if I only read the second half of the file.
> I tried croquet.exe -memory: 1024 without success.
>
> 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.:

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.


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
>
>
>


More information about the Squeak-dev mailing list