Posted 17 years ago
by Sean McLeod
Version: 4.0.0457
Platform: .NET 3.5
Environment: Windows Vista (32-bit)

Hi
I've used the gauges from the automotive sample pretty much as is for a boat engine simulator for a customer. Basically 2 tachometer gauges with embedded temperature gauges, 2 oil pressure gauges and a speedometer gauge.
The only real change is that I've disabled the dampening effect by setting both DampeningMaximumDuration and DampeningMinimumDuration to 0 on all the gauges.
The simulator reads the throttle positions from some external hardware and then drives the RPM, speedometer, etc. gauges. every 30ms based on a DispatchTimer.
What I've noticed is that if there is no throttle movement and in other words no movement of the pointers/needles on the gauges then the simulator runs fine for hours with CPU usage very low and steady and no increase in private bytes and the DispatchTimer firing very consistently every 30ms.
However with normal throttle movements after about 5 minutes I notice that the DispatchTimer event starts coming through very erratically, instead of a steady and consistent 30ms suddenly you see periods of it only arriving every 150-300ms. Secondly the CPU usage jumps up 20-30% and lastly if you take a look at memory usage in terms of private bytes you notice a steady and pretty continous climb.
The gauges pointers are data bound to a class implementing the standard INotifyPropertyChanged interface.To reproduce the problem without having to read from any external hardware etc. I just set the simulated gauge values to random values in the gauge's range in the DispatchTimer's event handler which fires every 30ms and the problem starts occuring within 30-60secs now.
The _scale member is toggled between -1.0 and 1.0 and while it's set to -1.0 the values are all negative making them out of range for the gauge pointer so the pointer doesn't move but all the data binding notifications happen and the simulator runs for hours in this state without any increase in private memory, without any cpu utilisation increase and with consistent DisptachTimer events.
But as soon as it's toggled to 1.0 the issues become apparent within 30-60secs.
So it appears that there is some memory leak or resource leak in terms of WPF geometry/visuals whenever the pointer moves.
I haven't had a chance to run a .Net memory profiler or WPFPerf to investigate further since I'm still busy finishing the simulation and hardware interfacing portions.
Thanks
I've used the gauges from the automotive sample pretty much as is for a boat engine simulator for a customer. Basically 2 tachometer gauges with embedded temperature gauges, 2 oil pressure gauges and a speedometer gauge.
The only real change is that I've disabled the dampening effect by setting both DampeningMaximumDuration and DampeningMinimumDuration to 0 on all the gauges.
The simulator reads the throttle positions from some external hardware and then drives the RPM, speedometer, etc. gauges. every 30ms based on a DispatchTimer.
What I've noticed is that if there is no throttle movement and in other words no movement of the pointers/needles on the gauges then the simulator runs fine for hours with CPU usage very low and steady and no increase in private bytes and the DispatchTimer firing very consistently every 30ms.
However with normal throttle movements after about 5 minutes I notice that the DispatchTimer event starts coming through very erratically, instead of a steady and consistent 30ms suddenly you see periods of it only arriving every 150-300ms. Secondly the CPU usage jumps up 20-30% and lastly if you take a look at memory usage in terms of private bytes you notice a steady and pretty continous climb.
The gauges pointers are data bound to a class implementing the standard INotifyPropertyChanged interface.
public class SimGaugeData : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
double _portRPM;
public double PortRPM
{
get { return _portRPM; }
set
{
if (value != _portRPM)
{
_portRPM = value;
OnPropertyChanged("PortRPM");
}
}
}
protected void OnPropertyChanged(string propName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propName));
}
}
}
Random random = new Random();
double _scale = 1.0;
void _simDataRefreshTimer_Tick(object sender, EventArgs e)
{
_simGaugeData.PortRPM = random.NextDouble() * 6700.0 * _scale;
_simGaugeData.PortWaterTemp = random.NextDouble() * 100.0 * _scale;
_simGaugeData.PortOilPressure = random.NextDouble() * 120.0 * _scale;
.......
}
But as soon as it's toggled to 1.0 the issues become apparent within 30-60secs.
So it appears that there is some memory leak or resource leak in terms of WPF geometry/visuals whenever the pointer moves.
I haven't had a chance to run a .Net memory profiler or WPFPerf to investigate further since I'm still busy finishing the simulation and hardware interfacing portions.
Thanks