-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory usage while validating #17
Comments
Unfortunately I'm a little rusty when it comes to system programming, been drifting away to full stack lately, so ymmv.
So to see what's actually going on it's either using valgrind (which I only us to profile the c part for with go's gc the output is not accurate), but to profile the go application itself I'd recommend to use go's pprof. |
I really can't remember ... it's about 6 years ago I needed this and ever since then this has been chuckling along quite unattended. And I'm not using the go wrapper but the elixir one I also wrote, for go's concurrency model needed way more attention to keep the whole thing performing in comparison with erlang's preemptive scheduler (I needed quite an extensive amount of concurrency). And also I'm not validating xmls of that size. I'm currently testing this a little for I'm curious. I personally don't think it's a leak but has sth. to do with memory allocation/deallocation. When I come up with sth. I'll keep you posted. |
I tested it further with different versions of libxml2 and unfortunately it didn't help - but maybe I missed the right one. Have you maybe come up with something? |
Not much ... for quite busy despite the holidays. Only thing I came up with is that while starting to prepare a pure c version to check if this would make a difference valgrind reported still reachable memory blocks with libxm2 version 2.9.4. Upgrading to 2.9.12 fixed that. No memory leaks in the wrapper code. |
I am facing an issue with huge memory usage while validating large XML files (about 90 MB).
I might be doing something wrong but there seems to be a memory leakage because the used memory grows after every file and never clears up until I restart the server.
My setup is an HTTP server with a handler that validates an uploaded XML file against a provided XSD.
My main func looks something like this:
and inside my handler I am doing something like this:
(I also tried creating the XSD handler only once inside main and injecting it into my service but that didn't help either)
When uploading a 90MB XML file and validating it with the XSD the memory usage looks like this:
After uploading it again the memory usage grows almost twice the size:
Unfortunately, the memory never frees up.
Now when using the same service again but commenting out the validation part:
err = xsdHandler.ValidateMem(fileContent, xsdvalidate.ParsErrDefault)
the memory usage looks like thisAfter the first time uploading the 90MB XML file:
After the second time uploading the file:
The file was still read into memory but after the GC kicks in it will be all freed up.
Any idea why the memory usage is so high and why it's only growing and never being freed up?
The text was updated successfully, but these errors were encountered: