To whom it may concern, in Unity.Collections.Memory.cs (Collections v1.4.0) there is the method CheckByteCountIsReasonable that prints out error messages where the strings are not prefixed with $:
[Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
internal static void CheckByteCountIsReasonable(long size)
{
if (size < 0)
throw new InvalidOperationException("Attempted to operate on {size} bytes of memory: nonsensical");
if (size > k_MaximumRamSizeInBytes)
throw new InvalidOperationException("Attempted to operate on {size} bytes of memory: too big");
}
This throws error messages that are in itself nonsensical.
4 Likes
Since this post is not too old, and relevant to my post I’m putting this here. I found a bug which causes this same error.
In the file “Library\PackageCache\com.unity.collections@1.4.0\Unity.Collections\AllocatorManager.cs” there’s this code:
public struct Block : IDisposable
{
public Range Range; // Contains "int Items"
public int BytesPerItem;
//...
public long Bytes => BytesPerItem * Range.Items; // <--- issue is here
public long AllocatedBytes => BytesPerItem * AllocatedItems; // <--- this is also not correct
That is a logical error. int*int !=long. There’s no point to this conversion, as the value is multiplied as Int32 before conversion. You need to cast one of them to long first. My project is failing now because this is not working correctly.