Chapel Documentation

Compiling and Running Chapel

  • Quickstart Instructions
  • Using Chapel
    • Where can I use Chapel?
    • Chapel Prerequisites
    • Setting up Your Environment for Chapel
    • Building Chapel
    • Compiling Chapel Programs
    • Editor Support
    • Chapel Man Page
    • Executing Chapel Programs
    • Multilocale Chapel Execution
    • Chapel Launchers
    • Chapel Tasks
    • Debugging Chapel Programs
      • Best Known Configurations for Debugging
      • Running in gdb/lldb with a Launcher
      • Debugging Multilocale Code
      • Debugging Memory-related Issues
        • Configuration Constants for Tracking Memory
      • Debugging Multithreaded Issues
      • Sanitizers
      • Useful Debug Features
    • Reporting Chapel Issues
  • Platform-Specific Notes
  • Technical Notes
  • Tools
  • Docs for Contributors

Writing Chapel Programs

  • Quick Reference
  • Hello World Variants
  • Primers
  • Language Specification
  • Standard Modules
  • Package Modules
  • Standard Layouts and Distributions
  • Mason Packages
  • Chapel Users Guide (WIP)

Language History

  • Chapel Evolution
  • Documentation Archives

Indexes

  • Chapel Module Index
  • Complete Docs Index
Chapel Documentation
  • Using Chapel
  • Debugging Chapel Programs
  • Debugging Memory-related Issues
  • View page source

Debugging Memory-related Issues

Chapel provides several tools and techniques for debugging memory-related issues in your programs. For many problems related to memory leaks or overall memory usage, you can use the built-in memory diagnostics features. Additionally, Chapel supports using external tools like AddressSanitizer (ASan) and Valgrind to help identify and resolve memory issues.

Configuration Constants for Tracking Memory

Chapel supports a number of configuration constants related to dynamic memory allocation for the compiler-generated executable. For full information on these configuration constants consult MemDiagnostics.

A brief synopsis of these configuration constants is as follows:

--memTrack

turn on memory tracking and enable reporting

--memStats

call printMemAllocStats() on normal termination

--memLeaksByType

call printMemAllocsByType() on normal termination

--memLeaks

call printMemAllocs() on normal termination

--memMax=int

set maximum level of allocatable memory

--memThreshold=int

set minimum threshold for memory tracking

--memLog=string

file to contain all memory reporting

--memLeaksLog=string

if set, append final stats and leaks-by-type here

Using Sanitizers

Using AddressSanitizer (ASan) with Chapel can help detect many common memory errors at runtime with minimal overhead. See Sanitizers for details on how to set up and use sanitizers with Chapel.

Using Valgrind

Valgrind is a powerful tool for detecting memory errors at runtime. See Valgrind for details on how to set up and use Valgrind with Chapel.

Previous Next

© Copyright 2025, Hewlett Packard Enterprise Development LP.