Project

Profile

Help

Bug #6396

open

(Another?) memory leak when using XQuery?

Added by Martin Honnen 13 days ago.

Status:
New
Priority:
Normal
Category:
Python API
Start date:
2024-04-16
Due date:
% Done:

0%

Estimated time:
Found in version:
12.4.2
Fixed in version:
Platforms:

Description

Based on the recent bug reports on memory leaks with SaxonC I am looking into whether some of my use cases also show leaks, it appears that doing XQuery evaluation causes some memory leak, a test case

from saxonche import PySaxonProcessor
import psutil

xquery = """<items>
{
random-number-generator(current-dateTime())?permute(1 to 20) ! <item>item {.}</item>
}
</items>"""

count = 0
process = psutil.Process()
prev = process.memory_info().rss
print(f"{prev:,}")
print()

with PySaxonProcessor() as proc:

    xquery_processor = proc.new_xquery_processor()

    for _ in range(100):

        xquery_processor.run_query_to_value(query_text=xquery)

        if (count := count + 1) % 10 == 0:
            m = process.memory_info().rss
            print(f"{m - prev:,}")
            prev = m

print()
print(f"{prev:,}")

leaks on both Windows

26,062,848

6,111,232
1,302,528
1,302,528
1,306,624
1,298,432
1,302,528
1,306,624
1,310,720
1,298,432
1,302,528

43,905,024

and Linux

34,836,480

10,715,136
1,310,720
1,318,912
1,310,720
1,273,856
1,347,584
1,081,344
1,351,680
1,351,680
1,351,680

57,249,792

(Haven't tested on Mac).

Can't tell whether the XML creation in the XQuery leaks the same as the XML parsing in https://saxonica.plan.io/issues/6391, so I file this as a separate bug.

No data to display

Please register to edit this issue

Also available in: Atom PDF