# System Monitor (sysmon) (/debugging/sysmon)



The System Monitor module provides real-time monitoring of system performance
metrics directly on your display. It supports both performance monitoring
(CPU usage and FPS) and memory monitoring (used memory and fragmentation).

Dependencies [#dependencies]

* Requires <ApiLink name="LV_USE_LABEL" /> = 1 in lv\_conf.h
* Requires <ApiLink name="LV_USE_OBSERVER" /> = 1 in lv\_conf.h
* Requires <ApiLink name="LV_USE_SYSMON" /> = 1 in lv\_conf.h

Usage [#usage]

Configuration [#configuration]

Enable in `lv_conf.h`:

```c title=" " lineNumbers=1
/* Main sysmon enable */
#define LV_USE_SYSMON 1

/* Performance monitor (CPU% and FPS) */
#define LV_USE_PERF_MONITOR 1

/* Memory monitor (used + fragmentation) */
#define LV_USE_MEM_MONITOR 1

/* Optional: refresh period in ms */
#define LV_SYSMON_REFR_PERIOD_DEF 300

/* Optional: log to console instead of screen */
#define LV_USE_PERF_MONITOR_LOG_MODE 0
```

Creating Monitors [#creating-monitors]

```c title=" " lineNumbers=1
/* Create generic monitor */
lv_obj_t * sysmon = lv_sysmon_create(lv_display_get_default());

/* Create performance monitor */
lv_sysmon_show_performance(NULL);  /* NULL = default display */

/* Create memory monitor */
lv_sysmon_show_memory(NULL);
```

Performance Monitor [#performance-monitor]

Tracks:

* FPS (Frames Per Second)
* CPU usage (%)
* Render time (ms)
* Flush time (ms)
* Self CPU usage (%) if enabled

Display format:

```text title=" " lineNumbers=1
32 FPS, 45% CPU
8 ms
```

Where:

* Line 1: FPS, Total CPU%
* Line 2: Total time (Render | Flush)

Pause and Resume [#pause-and-resume]

<ApiLink name="lv_sysmon_performance_pause" display="lv_sysmon_performance_pause(disp)" /> pauses the perf monitor.

<ApiLink name="lv_sysmon_performance_resume" display="lv_sysmon_performance_resume(disp)" /> resumes the perf monitor.

Memory Monitor [#memory-monitor]

Displays:

* Current memory usage (kB and %)
* Peak memory usage (kB)
* Fragmentation (%)

Display format:

```text title=" " lineNumbers=1
24.8 kB (76%)
32.4 kB max, 18% frag.
```

Positioning [#positioning]

Configure positions in lv\_conf.h:

```c title=" " lineNumbers=1
/* Top-right corner */
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_TOP_RIGHT

/* Bottom-right corner */
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
```

Implementation Details [#implementation-details]

Initialization [#initialization]

Maintains:

* Global memory monitor (`sysmon_mem`)
* Per-display performance structures

Performance Measurement [#performance-measurement]

Event-based collection:

| Event                    | Measurement              |
| ------------------------ | ------------------------ |
| LV\_EVENT\_REFR\_START   | Refresh interval start   |
| LV\_EVENT\_REFR\_READY   | Record refresh duration  |
| LV\_EVENT\_RENDER\_START | Render time start        |
| LV\_EVENT\_RENDER\_READY | Record render duration   |
| LV\_EVENT\_FLUSH\_\*     | Measure flush operations |

Timers [#timers]

* Performance: `perf_update_timer_cb`
* Memory: `mem_update_timer_cb`
* Default period: 300ms (<ApiLink name="LV_SYSMON_REFR_PERIOD_DEF" />)
