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
I'm working on bindings for Expat to implement my own XMPP library. Then i provide a way to set an environment variable to manually point to correct expat library. Everything is working as excepted, expat is begin called and parsing is working, but...
I had placed an Debug.WriteLine to see what happens here:
staticnintTryResolveExpat(stringname,Assemblyassembly,DllImportSearchPath?searchPath=default){if(name.Contains("libexpat",StringComparison.InvariantCultureIgnoreCase)){stringlibFile=Environment.GetEnvironmentVariable("EXPAT_LIBRARY_DIR");// fallback to default dll importerif(string.IsNullOrWhiteSpace(libFile))returndefault;// fallback to default dll importerif(!File.Exists(libFile))returndefault;Debug.WriteLine("Expat DLL Import Resolved: "+libFile);// attempt to load expat provided in env.returnNativeLibrary.Load(libFile,assembly,searchPath);}// fallback to default dll importerreturnnint.Zero;}
And for my surprise is calling multiple times, my guess this is causing some memory leak loading many times into memory?
1st: Get expat version (then next line you can see the version)
2nd: Is to invoke XML_CreateParser and return the parser pointer from unmanaged.
3rd~7th: calls is to set start/end handler, cdata open/close handler, comment handler and text handler.
8th... calls is sending data to parser (small chunks of 256 bytes for testing).
UPDATE: I've updated code to display address of returned nint pointer and its point to same library handle.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on bindings for Expat to implement my own XMPP library. Then i provide a way to set an environment variable to manually point to correct expat library. Everything is working as excepted, expat is begin called and parsing is working, but...
I had placed an
Debug.WriteLine
to see what happens here:And for my surprise is calling multiple times, my guess this is causing some memory leak loading many times into memory?
The file in question
PInvoke.cs
1st: Get expat version (then next line you can see the version)
2nd: Is to invoke
XML_CreateParser
and return the parser pointer from unmanaged.3rd~7th: calls is to set start/end handler, cdata open/close handler, comment handler and text handler.
8th... calls is sending data to parser (small chunks of 256 bytes for testing).
UPDATE: I've updated code to display address of returned
nint
pointer and its point to same library handle.But still this normal calling multipletimes even the library was resolved once?
Beta Was this translation helpful? Give feedback.
All reactions