Debugging MtxVec Applications

Debugging tools and techniques for MtxVec applications.

Debugger Visualizer (Delphi IDE):

  • Install the MtxVec debugger visualizer package into the IDE
  • CTRL+F6: View values in a table (works for Vector, TVec, Matrix, TMtx, etc.)
  • CTRL+ALT+F6: Draw values on a chart
  • Supports: Vector, TVec, VectorInt, TVecInt, Matrix, TMtx, MatrixInt, TMtxInt, clVector, clMatrix, 1D static/dynamic arrays, TSignal
  • Visualizer windows support docking and persist between debug sessions
  • Expressions are auto-updated on each step-over/step-into

Debugger Visualizer (Visual Studio):

Dew Math ships debugger visualizers for Visual Studio: the dialog in Dew.Math.Visualizer.UI, and one object source per runtime — Dew.Math.Visualizer.Windows, .Core and .Linux, matching Dew.Math, Dew.Math.Core and Dew.Math.Linux. Place them in the Visual Studio Visualizers folder; the debugger then offers them on any value of a supported type.

  • Registered for Vector, Matrix, VectorInt, MatrixInt, and any object deriving from TMtxVecBase, each under its own name ("Vector Visualizer", "Matrix Visualizer", "Dew Math Visualizer", …)
  • Open it from the magnifying-glass icon on a DataTip, or on an entry in the Watch, Locals or Autos window, and pick the visualizer by name

The window ("MtxVec Array Visualizer") offers:

  • View table — the values in a grid, with row and column indices, scientific or custom numeric formatting, automatic or fixed column width, and complex numbers optionally split into separate real and imaginary columns
  • View chart — the same values drawn on a chart
  • Math Expression — evaluate an expression over the data (y = x) and see the result without leaving the debugger
  • File > Open / Save, and Copy / Paste including Copy As Real and Paste As Complex, with a configurable text delimiter, for moving data in and out of other tools
  • Layout and formatting choices persist between debugging sessions

The object is copied out of the debugged process to be displayed. Turning on View > Editable makes the grid editable, but the edits stay in that copy — nothing is written back into the running program.

Sparse matrices (TSparseMtx) have no visualizer.

Manual watch expressions:

In Delphi IDE, use these watch expressions to inspect vector/matrix data:

In C# / Visual Studio, inspect the internal data arrays:

aVector.Values1D           // double[] in Watch window
aVector.SValues1D          // float[] for single-precision
aMatrix.Values1D           // matrix as flat double[]

Detecting memory leaks:

  1. Enable Assertions in compiler options (disables object cache)
  2. Use FastMM4 debugging features (or similar memory manager)
  3. After all MtxVec operations complete, check:
// Should be 0 — if not, you have a CreateIt without matching FreeIt
int vecLeaks = Controller.Pool[ThreadIndex].VecCacheUsed;
int mtxLeaks = Controller.Pool[ThreadIndex].MtxCacheUsed;
  1. On application exit, MtxVec raises an exception if any TVec/TMtx objects were not freed

Detecting memory overwrites:

  1. Enable Assertions → disables object cache, enables explicit range checks
  2. Enable Delphi range checking ({$R+}) for your own code
  3. Use FastMM debug mode for buffer overrun detection
  4. Disable memory pre-allocation for debugging:
Controller.SetVecCacheSize(0, 0);
Controller.SetMtxCacheSize(0, 0);

This makes access violations appear closer to the actual cause.

SSE/AVX alignment issues:

  • All MtxVec-allocated memory is properly aligned for SIMD
  • Problems occur when passing external (non-MtxVec) arrays to vectorized routines
  • Symptoms: access violations or subtle memory corruption
  • Debug: progressively comment out code blocks until the problem disappears

Release build checklist:

  • Assertions OFF (enables object cache, disables range checks)
  • Delphi range checking OFF for MtxVec-intensive code
  • FastMM in release mode (not debug mode)