Starting from version v1.3.0g , jemalloc embedded in ProxySQL is compiled with
--enable-prof, allowing memory profiling.
Memory profiling is disabled by default.
Start ProxySQL with memory profiler
For starting ProxySQL memory profiling it’s enough to connect to Admin interface, and execute the following command:
PROXYSQL MEMPROFILE START
After executing this command, ProxySQL will start writing profile dumps with names
proxysql.<pid>.<seq>.i<iseq>.heap in one of the following two locations:
- If executed in foreground (i.e. with -f, –foreground command line option). The files will be written in the folder from which ProxySQL is executed.
- If executed in background (i.e. without -f, –foreground option) or via the init script the files will be written in ProxySQL specified datadir, which by default is /var/lib/proxysql.
After all the desired data has been collected, to stop memory profiling, ProxySQL needs to be restarted.
How to report a memory leak?
To report a memory leak:
- Start ProxySQL with memory profiling enabled and collect memory dumps until being certain that the leak is consuming a representative enough ammount of memory.
Please create a tarball with the dumps generated by jemalloc profiler and either create an issue following the issue template at ProxySQL GitHub issues page.
- Please note that even if the leak is present, finding it without having enough profiling data could be very tricky. As it could hide behind the allocation patterns of a particular workload.
Legacy: Profiling before ProxySQL v1.4.0
Using init script
If you are running ProxySQL using init script
/etc/init.d/proxysql , it is enough to add the following line before the point when the process is started, for example at around line 19 in
Without init script
If you are running ProxySQL without init script
/etc/init.d/proxysql , you need to ensure that the environment variable is set before starting
proxysql. For example, if you run ProxySQL in the foreground, you need to execute it similar to the following:
MALLOC_CONF="xmalloc:true,lg_tcache_max:16,purge:decay,prof:true,prof_leak:true,lg_prof_sample:18,lg_prof_interval:30" proxysql -f -c /etc/proxysql.cnf
To disable profiling, ProxySQL needs to be restarted without