Bug #70078 [Opn]: Memleak when calling PHP functions from XSL with nodes as parameter

From: Date: Mon, 27 Jan 2020 22:11:44 +0000
Subject: Bug #70078 [Opn]: Memleak when calling PHP functions from XSL with nodes as parameter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225173@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70078&edit=1

 ID:                 70078
 User updated by:    not-implemented at mark-plomer dot de
 Reported by:        not-implemented at mark-plomer dot de
 Summary:            Memleak when calling PHP functions from XSL with
                     nodes as parameter
 Status:             Open
 Type:               Bug
 Package:            XSLT related
 Operating System:   any
-PHP Version:        5.6.11
+PHP Version:        7.3.11
 Block user comment: N
 Private report:     N

 New Comment:

Problem still present in 7.3.11


Previous Comments:
------------------------------------------------------------------------
[2015-09-10 08:23:49] mike@php.net

Maybe Rob can have a look at it, as we're lost with these ext/libxml internals...

------------------------------------------------------------------------
[2015-09-09 18:40:16] mplomer at gmx dot de

Oh, I see, my report was not clear enough:

The memory is not freed, even after processing the request - I re-tested the snippet under Apache
(mod_php) / Linux now. (I had to reduce the dummy XML size by factor 10, otherwise the process just
crashed - memory_limit also does not apply here).

AFTER the request is complete I see a memory usage (RSS) of ~ 350 MB:

root     28237  0.0  0.0 421800   112 ?        Ss   Sep07   0:06 /usr/sbin/apache2 -k start
www-data 17175  0.0  4.8 510936 24328 ?        S    06:25   0:11  \_ /usr/sbin/apache2 -k start
www-data 18672  0.0 69.7 911320 353168 ?       S    09:10   0:10  \_ /usr/sbin/apache2 -k start
...........

You are right, this still _may_ not be a "real" memleak ... but anyway, I think the
recursive clone on the complete DOM node on every function call is wrong - for performance reasons -
even if it gets fixed by freeing the clone immediately after the function call.

------------------------------------------------------------------------
[2015-09-09 17:58:50] cmb@php.net

To clarify: there may not really be a memory *leak*, but at least
the intermediate memory consumption is enormous:

> Until 5.4.23 you have ~25 MB RAM usage of the process at the end
> Starting with 5.4.24 you have ~1030 MB RAM usage of the process
> at the end

------------------------------------------------------------------------
[2015-09-09 16:29:26] mplomer at gmx dot de

As described, I checked the process memory usage (under Windows in Task-Manager - should be the same
with "ps" on unix) - memory_get_usage() does not cover this. I don't know what
Valgrind checks exactly. And I don't know, which memory allocator libxml/libxslt uses.

By the way you can also reproduce the problem by measuring the performance of transformToXML(),
which is much much slower than with 5.4.23.

Just tell me if you need more info.

------------------------------------------------------------------------
[2015-09-09 15:50:52] mike@php.net

How did you confirm the memleak? Valgrind doesn't complain for me...

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=70078


--
Edit this bug report at https://bugs.php.net/bug.php?id=70078&edit=1


Thread (16 messages)

« previous php.bugs (#225173) next »