You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `memprof_enabled()` function can be called to check whether profiling is
67
-
currently enabled.
86
+
> :information_source:The `memprof_enabled_flags()` function can be called to
87
+
> check whether profiling is currently enabled in `dump_on_limit` mode.
68
88
69
-
### 2. Dumping the profile
89
+
### Step 2: Dumping the profile
70
90
71
-
When profiling is enabled, and once the program has reached a large memory usage,
72
-
call ``memprof_dump_callgrind()`` or one it its variants to save the full
73
-
profiling information to a file.
91
+
In this mode, `memprof` will automatically save the profile if the program
92
+
exceeds the memory limit (when PHP triggers an error like `Fatal error: Allowed
93
+
memory size of 15728640 bytes exhausted (tried to allocate 1024 bytes)` error).
74
94
75
-
* Calling the function multiple times is not necessary
76
-
* Waiting for a high memory usage before saving the profile makes it easier to
77
-
find a leak
95
+
By default, the profile is saved in a file named `memprof.callgrind.*` in `/tmp`
96
+
or `C:\Windows\Temp`.
78
97
79
-
### 3. Visualizing the profile
98
+
### Step 3: Visualizing the profile
80
99
81
100
The recommended way to visualize the result is to use Kcachegrind (on Linux) or Qcachegrind (on MacOS, Windows). Google Perftools are also supported. See the documentation of ``memprof_dump_callgrind()`` and variants.
82
101
@@ -100,35 +119,34 @@ Use Homebrew: https://formulae.brew.sh/formula/qcachegrind
100
119
101
120
Download it from https://sourceforge.net/projects/qcachegrindwin/
102
121
103
-
### Usage example
122
+
##Advanced usage
104
123
105
-
```
106
-
<?php // test.php
124
+
### Profile trigger
107
125
108
-
do_some_work();
126
+
Profiling is enabled at request startup when one of these is true:
109
127
110
-
if (function_exists('memprof_enabled') && memprof_enabled()) {
0 commit comments