elastic / apm-agent-php

Apache License 2.0
251 stars 69 forks source link

Memory problem since 1.11.0 #1159

Closed JoniJnm closed 2 weeks ago

JoniJnm commented 1 month ago

Hi,

I'm using a Dockerfile to run a symfony application

I'm installing APM with:

ARG APM_VERSION="v1.10.0/apm-agent-php_1.10.0_all.deb"
RUN set -e; \
    curl -s -L -o /tmp/apm-agent.deb https://github.com/elastic/apm-agent-php/releases/download/${APM_VERSION}; \
    apt install /tmp/apm-agent.deb; \
    rm -f /tmp/apm-agent.deb

All works OK, but when I upgrade to 1.11.0 I have memory problems

I can't reproduce the problem outside my project I can't share it (it's not my project, the owner is a company).

Let me share the output depending on the APM version installed and some APM config:

Installing v1.10.0/apm-agent-php_1.10.0_all.deb

CAPTURE_ERRORS OFF:

$ rm -Rf var/cache/* && ELASTIC_APM_CAPTURE_ERRORS="false" bin/console cache:warmup -n

 // Warming up the cache for the dev environment with debug false                                                       

 [OK] Cache for the "dev" environment (debug=false) was successfully warmed.                                            

peak memory usage (MB): 168

CAPTURE_ERRORS ON:

$ rm -Rf var/cache/* && ELASTIC_APM_CAPTURE_ERRORS="true" bin/console cache:warmup -n

 // Warming up the cache for the dev environment with debug false                                                       

 [OK] Cache for the "dev" environment (debug=false) was successfully warmed.                                            

peak memory usage (MB): 166

Installing v1.11.0/apm-agent-php_1.11.0_amd64.deb

CAPTURE_ERRORS OFF:

$ rm -Rf var/cache/* && ELASTIC_APM_CAPTURE_ERRORS="false" bin/console cache:warmup -n

 // Warming up the cache for the dev environment with debug false                                                       

 [OK] Cache for the "dev" environment (debug=false) was successfully warmed.                                            

peak memory usage (MB): 168

CAPTURE_ERRORS ON:

$ rm -Rf var/cache/* && ELASTIC_APM_CAPTURE_ERRORS="true" bin/console cache:warmup -n
PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /app/vendor/symfony/dependency-injection/Compiler/AutowireRequiredMethodsPass.php on line 76

Same problem with 1.13.0

Do you know what is happening?

Some info:

php mods enabled:

app@fd77ede50f3f:/etc/php/8.2/cli/conf.d$ ls
10-mysqlnd.ini  20-apcu.ini      20-dom.ini       20-gettext.ini   20-intl.ini       20-phar.ini      20-simplexml.ini  20-tokenizer.ini  20-yaml.ini         99-elastic-apm-custom.ini
10-opcache.ini  20-bcmath.ini    20-exif.ini      20-gmp.ini       20-mbstring.ini   20-posix.ini     20-sockets.ini    20-uuid.ini       20-zip.ini
10-pdo.ini      20-calendar.ini  20-ffi.ini       20-iconv.ini     20-mongodb.ini    20-readline.ini  20-sysvmsg.ini    20-xmlreader.ini  30-ds.ini
15-xml.ini      20-ctype.ini     20-fileinfo.ini  20-igbinary.ini  20-mysqli.ini     20-redis.ini     20-sysvsem.ini    20-xmlwriter.ini  90-company.ini
20-amqp.ini     20-curl.ini      20-ftp.ini       20-imagick.ini   20-pdo_mysql.ini  20-shmop.ini     20-sysvshm.ini    20-xsl.ini        98-elastic-apm.ini
SebaGnich commented 1 month ago

We have the same issue with 1.13.0 and PHP 8.3.

JoniJnm commented 1 month ago

@SebaGnich does it works with 1.10.0?

SebaGnich commented 1 month ago

@JoniJnm With 1.10 and PHP 8.2 it worked, yes

intuibase commented 3 weeks ago

Steps to reproduce set in ini:

memory_limit = 128M

run this code in cli:

for($i = 0; $i < 10000000; $i++) {
    try {
        throw new ErrorException("This is exception");
    } catch (Exception $e) {
    }
}

var_dump(memory_get_peak_usage());