Skip to content
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

BSTR memory leaks #5184

Closed
nvaccessAuto opened this issue Jun 26, 2015 · 6 comments
Closed

BSTR memory leaks #5184

nvaccessAuto opened this issue Jun 26, 2015 · 6 comments

Comments

@nvaccessAuto
Copy link

Reported by DelRed on 2015-06-26 09:10
Hello, I use UI Automation with my controls, I have noticed that when I use NVDA and just tab all controls on my form - it cases memory leaks in my application. If I use JAWS - there is no such problem.
I think that the issue is that when I return VARIANT with BSTR (for example as answer to UIA_NamePropertyId), or just BSTR (IValueProvider::get_Value(BSTR *pRetVal)) I use SysAllocString, so after NVDA use this BSTR it should call SysFreeString.

@nvaccessAuto
Copy link
Author

Comment 2 by jteh on 2015-06-26 12:01
What makes you suspect BSTR allocation as opposed to, say, holding UI Automation elements? NVDA accesses UI Automation out-of-process, so the string in your process is probably freed by COM after it is marshaled, rather than when NVDA frees it.

Also, do you see these leaks when you use Narrator? The way NVDA consumes UIA is probably more similar to Narrator.

@nvaccessAuto
Copy link
Author

Comment 3 by DelRed (in reply to comment 2) on 2015-06-26 13:00
Replying to jteh:

What makes you suspect BSTR allocation as opposed to, say, holding UI Automation elements? NVDA accesses UI Automation out-of-process, so the string in your process is probably freed by COM after it is marshaled, rather than when NVDA frees it.

Also, do you see these leaks when you use Narrator? The way NVDA consumes UIA is probably more similar to Narrator.

There are no leaks when I use Narrator.
I suspect BSTR allocation, because it it the only thing that I allocate in my providers. And memory leaks when I simply circle through controls (I just hold Tab). I see it like this: NVDA ask for element's name, I allocate string, but it is not freed then.

@nvaccessAuto
Copy link
Author

Comment 4 by jteh on 2015-06-28 23:08
You (or at least UI Automation) would also be allocating instances of UIA elements.

Ctypes/comtypes manages freeing of BSTR in NVDA. We actually had to work around a bug a while ago where ctypes/comtypes was calling SysFreeString twice in certain cases. I don't think this is related, but I could be missing something. Mick may have a better idea on this one, but he's away for a couple of weeks.

It'd be great if you can provide a simple compiled test case that shows this behaviour.

@nvaccessAuto
Copy link
Author

Comment 5 by mdcurran on 2015-09-10 04:56
Windows does not free BSTRs straight away by default. To ensure memory is really not being freed, set the OANOCACHE environment variable to 1 before testing your app.
But as mentioned above, without a testcase we cannot debug this any further.

@LeonarddeR
Copy link
Collaborator

Although a very interesting ticket, I'm afraid we can't contact the original author any more, and as @michaelDCurran stated in #5184 (comment), a test case is needed for this. I'm leaning towards a close.

@ehollig
Copy link
Collaborator

ehollig commented Oct 13, 2018

Closing, as suggested by @LeonarddeR in #5184 (comment)

@ehollig ehollig closed this as completed Oct 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants