/// <summary> /// Constructs a new <see cref="StandardSopFrameData"/>. /// </summary> /// <param name="frameNumber">The 1-based number of this frame.</param> /// <param name="parent">The parent <see cref="ISopDataSource"/> that this frame belongs to.</param> /// <param name="regenerationCost">The approximate cost to regenerate the pixel and/or overlay data.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="parent"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="frameNumber"/> is zero or negative.</exception> protected StandardSopFrameData(int frameNumber, StandardSopDataSource parent, RegenerationCost regenerationCost) : base(frameNumber, parent) { _largeObjectContainerData.RegenerationCost = regenerationCost; }
/// <summary> /// Constructs a new <see cref="DicomMessageSopFrameData"/> /// </summary> /// <param name="frameNumber">The 1-based number of this frame.</param> /// <param name="parent">The parent <see cref="DicomMessageSopDataSource"/> that this frame belongs to.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="parent"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="frameNumber"/> is zero or negative.</exception> /// <param name="regenerationCost">The approximate cost to regenerate the pixel and/or overlay data.</param> public DicomMessageSopFrameData(int frameNumber, DicomMessageSopDataSource parent, RegenerationCost regenerationCost) : base(frameNumber, parent, regenerationCost) { _frameIndex = frameNumber - 1; }
public override void Collect(MemoryCollectionArgs collectionArgs) { _largeObjectEnumerator = collectionArgs.LargeObjectContainers.GetEnumerator(); _regenerationCost = RegenerationCost.Low; //TODO (Time Review): Use Environment.TickCount? _collectionStartTime = DateTime.Now; _timeSinceLastCollection = _collectionStartTime - _lastCollectionTime; TimeSpan thirtySeconds = TimeSpan.FromSeconds(30); if (_timeSinceLastCollection < thirtySeconds) { Platform.Log(LogLevel.Debug, "Time since last collection is less than 30 seconds; adjusting to 30 seconds."); _timeSinceLastCollection = thirtySeconds; } _maxTimeSinceLastAccess = _timeSinceLastCollection; _maxTimeSinceLastAccessDecrement = TimeSpan.FromSeconds(_timeSinceLastCollection.TotalSeconds / 3); _totalNumberOfCollections = 0; _totalBytesCollected = 0; _totalLargeObjectsCollected = 0; _totalContainersUnloaded = 0; try { CodeClock clock = new CodeClock(); clock.Start(); Collect(); clock.Stop(); PerformanceReportBroker.PublishReport("Memory", "Collect", clock.Seconds); } catch (Exception e) { Platform.Log(LogLevel.Warn, e, "Default memory management strategy failed to collect."); } finally { DateTime collectionEndTime = DateTime.Now; if (_totalContainersUnloaded > 0) { _lastCollectionTime = collectionEndTime; } _largeObjectEnumerator = null; TimeSpan totalElapsed = collectionEndTime - _collectionStartTime; MemoryCollectedEventArgs finalArgs = new MemoryCollectedEventArgs( _totalContainersUnloaded, _totalLargeObjectsCollected, _totalBytesCollected, totalElapsed, true); if (_totalNumberOfCollections != 0 || _totalBytesCollected != 0 || _totalLargeObjectsCollected != 0 || _totalContainersUnloaded != 0) { Platform.Log(LogLevel.Info, "Large object collection summary: freed {0} MB in {1} seconds and {2} iterations, Total Containers: {3}, Total Large Objects: {4}", _totalBytesCollected / (float)OneMegabyte, totalElapsed.TotalSeconds, _totalNumberOfCollections, _totalContainersUnloaded, _totalLargeObjectsCollected); } OnMemoryCollected(finalArgs); } }
public override void Collect(MemoryCollectionArgs collectionArgs) { _largeObjectEnumerator = collectionArgs.LargeObjectContainers.GetEnumerator(); _regenerationCost = RegenerationCost.Low; //TODO (Time Review): Use Environment.TickCount? _collectionStartTime = DateTime.Now; _timeSinceLastCollection = _collectionStartTime - _lastCollectionTime; TimeSpan thirtySeconds = TimeSpan.FromSeconds(30); if (_timeSinceLastCollection < thirtySeconds) { Platform.Log(LogLevel.Debug, "Time since last collection is less than 30 seconds; adjusting to 30 seconds."); _timeSinceLastCollection = thirtySeconds; } _maxTimeSinceLastAccess = _timeSinceLastCollection; _maxTimeSinceLastAccessDecrement = TimeSpan.FromSeconds(_timeSinceLastCollection.TotalSeconds / 3); _totalNumberOfCollections = 0; _totalBytesCollected = 0; _totalLargeObjectsCollected = 0; _totalContainersUnloaded = 0; try { CodeClock clock = new CodeClock(); clock.Start(); Collect(); clock.Stop(); PerformanceReportBroker.PublishReport("Memory", "Collect", clock.Seconds); } catch (Exception e) { Platform.Log(LogLevel.Warn, e, "Default memory management strategy failed to collect."); } finally { DateTime collectionEndTime = DateTime.Now; if (_totalContainersUnloaded > 0) _lastCollectionTime = collectionEndTime; _largeObjectEnumerator = null; TimeSpan totalElapsed = collectionEndTime - _collectionStartTime; MemoryCollectedEventArgs finalArgs = new MemoryCollectedEventArgs( _totalContainersUnloaded, _totalLargeObjectsCollected, _totalBytesCollected, totalElapsed, true); if ( _totalNumberOfCollections != 0 || _totalBytesCollected != 0 || _totalLargeObjectsCollected != 0 ||_totalContainersUnloaded != 0) Platform.Log(LogLevel.Info, "Large object collection summary: freed {0} MB in {1} seconds and {2} iterations, Total Containers: {3}, Total Large Objects: {4}", _totalBytesCollected/(float)OneMegabyte, totalElapsed.TotalSeconds, _totalNumberOfCollections, _totalContainersUnloaded, _totalLargeObjectsCollected); OnMemoryCollected(finalArgs); } }