[squeak-dev] FileStreams Limit
leves at caesar.elte.hu
Thu Feb 17 08:55:43 UTC 2022
On Thu, 17 Feb 2022, Jörg Belger wrote:
> Is there a limit with file streams? I cannot open more than 238 on my macOSX. The 239th fails and Squeak runs with 100% cpu power. I changed then the method StandardFileStream>>open:forWrite: and removed the #retryWithGC:until:forFileNamed:, because it looked to me, that it does not much things. Now I get a <nil> back from the primitive.
> | directory streams |
> directory := FileDirectory default directoryNamed: 'Test'.
> directory assureExistence.
> streams := (1 to: 239)
> collect: [:index | directory fileNamed: 'test', index printString].
> streams do: #close
There is a limit on the maximum number of external semaphores provided by
the VM. Each socket uses 3 external semaphores and each file uses one.
The default limit is 256 which is very conservative and I hope the next
release will ship with at least 4096 as default.
Anyway, you can check the current value with
and set it with
Smalltalk maxExternalSemaphores: 4096
Some care must be taken not to change the limit while signals are expected
to be processed (e.g. when you have activity on those sockets/files),
because there's a short period during the resize while the VM may
fail to signal the semaphores.
More information about the Squeak-dev