> On Sep 12, 2016, at 9:21 PM, Gerriet M. Denkmann <gerr...@mdenkmann.de> wrote:
> 
> READ of size 1776 at 0x61c0000e68a0 thread T0
>    #0 0x1000516f3 in wrap_memcpy (libclang_rt.asan_osx_dynamic.dylib+0x406f3)
>    #1 0x100f85a88 in __swift_memcpy_array1_1 (libswiftCore.dylib+0x1dea88)
>    #2 0x100dd9a3e in _TZFSa11_copyBufferfRGVs12_ArrayBufferx_T_ 
> (libswiftCore.dylib+0x32a3e)
>    #3 0x100dd7495 in _TFSaap9subscriptFSix (libswiftCore.dylib+0x30495)

One of the writes is copying the array buffer, while presumably a bunch of 
other threads are trying to write to that buffer. Bad news.

Swift arrays are not thread-safe.

> When I use a [Bool] of size 1,000,000,000, the memory footprint goes up by 
> more than 1 GB. Looks like Swift uses only one bit per byte.

The Bool type is one byte in size.

C++ has a specialization for std::vector<bool> that makes it a true bit array, 
but I’m not sure if Swift’s generic system is powerful enough to be able to 
entirely switch out the implementation based on the parameter type.

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to