Debugger features help to find memory leaks

You can use the debugger $CALLSTACK and TracePoints to find memory leaks. Memory leaks are very tedious to find. Often they don’t affect an application at all except a gradual performance slowdown on a customer machine. Leaks can be found in old code bases that have multiple authors over years, with different programming styles and…

2

Create managed Tests for native code

In the old days of code development, the developer would do several steps repeatedly: 1. edit the code 2. Save 3. Compile 4. Link 5. Deploy (if necessary) 6. Start (or switch to) the debugger 7. Start the app under the debugger. 8. Examine the code behavior changes with breakpoints and other debugger windows. This…

0

Export your data to Excel using CSV and all data appears in one column

In many prior posts, I export data to Excel via writing to a TEMP file and just starting that TEMP file, which starts Excel, if Excel is on the machine.   var tempFileName = System.IO.Path.ChangeExtension( System.IO.Path.GetTempFileName(), "csv"); System.IO.File.WriteAllText( tempFileName, SomeText); If the format of the output is comma delimited, with the first row having column…

0

Fish vs Sharks: Predator Prey simulation

Many years ago, A.K. Dewdney wrote an article in Scientific American Magazine (December 1984) about a world called Wator, which is a world of fish and sharks. The world is a cellular automaton with each cell being in one of three states: empty, a shark, or a fish. The world is calculated repeatedly, each cycle…

0

Logo Turtle Graphics in WPF

Logo is a programming language that somehow involves a turtle. Imagine a turtle on a large piece of paper on the floor. The  turtle has a pen. You can command the turtle to go forward, turn right, then repeat 4 times to draw a square. The last time I wrote about Logo (in 2006) I…

2

Surface Pro 3 cursor disappears

I like my new Surface Pro 3. Things were working fine and all of a sudden, the cursor would disappear. I just have the Type Cover and a memory card installed: no other hardware. Narrowing down the issue: if I move my finger in circles on the trackpad to make the cursor move in small…

44

DPI Aware Sample

Last time I showed a way to use immediate mode graphics in WPF by showing balls bouncing around in a window. This time, we’ll add a few features. I’ve made the program DPI (Dots Per Inch) Aware. On most machines it works correctly. However, on my brand new Surface Pro 3 (really nice!), the screen…

0

WPF immediate mode graphics

Windows Presentation Foundation (WPF) is a retained mode graphics system (see Retained Mode Versus Immediate Mode). That means when you write code to draw something, you’re actually declaring a set of graphics objects (like lines or shapes) to use. The graphics library then creates a model in memory. This model changes in response to your…

1

How to monitor and respond to memory use

A colleague asked me how to run code in response to low memory condition. Apparently, data is buffered and can be flushed to disk or a server when memory gets low. So I showed him the code below. Start Visual Studio File->New->Project->C# WPF application Paste in the code below in the MainWindow.Xaml.cs file Then hit…

0

Async methods failures can be hard to diagnose

Using asynchronous programming can make your application be more responsive and seem faster. However, beware of possible failures that are hard to diagnose. I’ve just been analyzing some of these crash reports that are sent to Microsoft from the Problem Reporting Settings (below). A big part of writing programs is calling other programs, or APIs,…

0