-
Notifications
You must be signed in to change notification settings - Fork 78
Local runtime (Java) memory leak with Inspector opened #1400
Comments
So it turns out it's because a managed worker runs way faster then one running inside UnityEditor, so it generate enormous traffic toward the runtime. After limit |
Unfortunately I have to reopen this since the memory usage will randomly grows, like, after staying at 4GB for 5 minutes, it suddenly goes up to 13GB, then after 2 minutes, it goes up to 15GB. Continuing to do these tests, will let you know the results.
The code of the system setting Position for reproducing purpose: using Improbable;
using Improbable.Gdk.Core;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Transforms;
[UpdateInGroup(typeof(SpatialOSUpdateGroup))]
public class SpatialPositionFromTranslationSystem : SystemBase
{
EntityQuery query;
protected override void OnCreate()
{
query = GetEntityQuery(ComponentType.ReadOnly<Translation>(), ComponentType.ReadWrite<Position.Component>(), ComponentType.Exclude<NewlyAddedSpatialOSEntity>());
query.SetChangedVersionFilter(typeof(Translation));
}
protected override void OnUpdate()
{
SyncJob job = new SyncJob
{
Translation_Type = GetArchetypeChunkComponentType<Translation>(),
Position_Type = GetArchetypeChunkComponentType<Position.Component>()
};
job.ScheduleParallel(query).Complete();
}
[BurstCompile]
protected struct SyncJob : IJobChunk
{
[ReadOnly] public ArchetypeChunkComponentType<Translation> Translation_Type;
public ArchetypeChunkComponentType<Position.Component> Position_Type;
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
{
var translations = chunk.GetNativeArray<Translation>(Translation_Type);
var positions = chunk.GetNativeArray<Position.Component>(Position_Type);
var cache = new Position.Component();
var coordCache = new Coordinates();
for (int i = 0; i < translations.Length; i++)
{
coordCache.CopyFromUnityFloat3(translations[i].Value);
cache.Coords = coordCache;
positions[i] = cache;
}
}
}
}
public static class SpatialCoordsExtentsion
{
public static float3 ToUnityFloat3 (this global::Improbable.Coordinates source)
{
return new float3((float) source.X, (float) source.Y, (float) source.Z);
}
public static global::Improbable.Coordinates FromUnityFloat3 (float3 source)
{
return new global::Improbable.Coordinates(source.x, source.y, source.z);
}
public static void CopyFromUnityFloat3 (this ref global::Improbable.Coordinates dest, float3 source)
{
dest.X = source.x;
dest.Y = source.y;
dest.Z = source.z;
}
} |
I've reproduced the random memory leak, it happens when Inspector opened. Another minor issue along with this: Not sure if these only happens when CPU is 100% loaded. (When inspector opens running these tests, CPU are at 100% all the time) |
Does this happen with just the Inspector, or also Inspector V2? Note that sening an update on |
I did not test with InspectorV2, I've tried it multiple times though, but it's not as intuitive as V1 😅
It's the java process. It always occupy a lot of CPU usage, I am thinking it may be related to what you said below.
Thank you, that's very valuable info! |
Yes it is recommended to only update |
OK, thanks for the heads up. I am in the progress to finish up a demo project and moving to cloud, so may not be able to reproduce the issue in near future, as we yet have a conclusion, I'll let this remain opened, will definitely report back if it happens again. |
Outdated description. See comments below first.
Environment
i7-9700 / 32GB
Windows 10 1909 / Unity 2019.3.7f1
OpenJDK Runtime Environment (build 14.0.1+7)
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
The text was updated successfully, but these errors were encountered: