Beispiel #1
0
        public void InvokeReset()
        {
            var handler = Lost;

            if (handler != null)
            {
                handler(this);
            }

            try
            {
                SetRenderTarget(null);

                if (_backBuffer != null)
                {
                    _backBuffer.Dispose();
                    _backBuffer = null;
                }

#if DEBUG_REFERENCES
                IEnumerable <ObjectReference> references = ObjectTracker.FindActiveObjects();

                foreach (var reference in references)
                {
                    if (reference.IsAlive)
                    {
                        Tracer.Warn(
                            "{0} reference still alive, if object is not managed, consider calling dispose when the device context is resetting.\n\n{0} Created at:\n{1}",
                            reference.Object.GetType(),
                            reference.StackTrace);
                    }
                }
#endif

                _device.Reset(PresentationParameters);
                _viewport = _device.Viewport;
            }
            catch (SharpDXException e)
            {
#if DEBUG
                string errorMessage = ErrorManager.GetErrorMessage(e.ResultCode.Code);

                Tracer.Error(errorMessage);
#endif
                Tracer.Error(e);
                throw;
            }

            handler = Reset;

            if (handler != null)
            {
                handler(this);
            }
        }
 public static void Finish()
 {
     if (ObjectTracker.FindActiveObjects().Count > 0)
     {
         Trace.WriteLine(ObjectTracker.ReportActiveObjects());
     }
     else
     {
         Trace.WriteLine("Zero leaked objects.");
     }
 }
Beispiel #3
0
        private static void StartSim(int adapterIndex)
        {
            using (RenderBase rb = new RenderBase(adapterIndex))
            {
                rb.Run();
            }

            var liveObjs = ObjectTracker.FindActiveObjects();

            Console.WriteLine(liveObjs.Count + " live objects");
            foreach (var o in liveObjs)
            {
                Console.WriteLine(o.ToString());
            }
            //Console.WriteLine(ObjectTracker.ReportActiveObjects());
            //Console.ReadKey(true);
        }
        private void On5Seconds()
        {
            var c = _runtimeConfig;

            var now = DateTime.UtcNow;

            var dxStat     = c.Dx?.Pool.CleanUp(now);
            var packetStat = _streamer.PacketPool.CleanUp();
            var frameStat  = _streamer.FramePool.CleanUp();

            var fails       = _streamer.GetDxFailureCounter();
            var failsString = fails > 0 ? $"; {fails} FAILURES" : "";

            // statistics
            lock (this)
            {
                if (_current1SecondStatistics == null)
                {
                    return;
                }
                var msg = string.Join("  ", _current1SecondStatistics.Select(s => $"{s.Name}({s.Data})"));
                Core.LogInfo("stat: " + msg + "; " + GetPoolData(dxStat, packetStat, frameStat) + failsString);
            }


            // dump config
            var ordered = c.Nodes.OrderBy(s => s.item.Name.SortId()).ToList();

            if (_lastVersionConfigDump != c.Version ||
                _configDumpCounter++ > 10)
            {
                _lastVersionConfigDump = c.Version;
                _configDumpCounter     = 0;

                var configs = ordered.Where(s => s.setup != null).Select(s => $"{s.item.Name}[{s.setup.ToString().TrimEnd()}]");
                Core.LogInfo("config: " + string.Join("  ", configs));

                if (Configuration.EnableObjectTracking)
                {
                    var objs    = ObjectTracker.FindActiveObjects();
                    var grouped = objs.GroupBy(s => s.Object.Target?.GetType().Name).Select(s => $"{s.Key}:{s.Count()}");
                    Core.LogInfo("dx: " + string.Join("; ", grouped));
                }
            }
        }
        /// <summary>
        ///   Reports active SharpDX objects
        /// </summary>
        internal static void ReportObjects()
        {
            List <ObjectReference> objects = ObjectTracker.FindActiveObjects();

            if (!objects.Any())
            {
                Log.Info("no active objects to be reported!");
                return;
            }

            Log.Warn($"*** there are {objects.Count} active object(s) ***");

            foreach (ObjectReference obj in objects)
            {
                Log.Warn($"active {obj.Object.Target.GetType()} ({(obj.IsAlive ? "alive" : "dead")})");

                foreach (string line in obj.StackTrace.Split('\n').Where(l => l.Contains(".cs:")))
                {
                    Log.Warn(line);
                }
            }
        }