Skip to content

Fix memory leak in COMLateBindingObject#getStringProperty#869

Merged
matthiasblaesing merged 1 commit intojava-native-access:masterfrom
matthiasblaesing:com_memory_leak_string_property
Oct 30, 2017
Merged

Fix memory leak in COMLateBindingObject#getStringProperty#869
matthiasblaesing merged 1 commit intojava-native-access:masterfrom
matthiasblaesing:com_memory_leak_string_property

Conversation

@matthiasblaesing
Copy link
Copy Markdown
Member

Variants that hold strings utilize a BSTR. BSTRs are special in the sense, that
they are allocated by SysAllocString and freed by SysFreeString and the memory
needs to be explicitly cleared.

For Variants this is handled by VariantClear. VariantClear clears the data
contained in the Variant and frees that data (not the Variant itself!). The
Variant structure is caller allocated and in JNA located in auto-allocated
memory and does not need to be explicitly freed.

This closes #867

Variants that hold strings utilize a BSTR. BSTRs are special in the sense, that
they are allocated by SysAllocString and freed by SysFreeString and the memory
needs to be explicitly cleared.

For Variants this is handled by VariantClear. VariantClear clears the data
contained in the Variant and frees that data (not the Variant itself!). The
Variant structure is caller allocated and in JNA located in auto-allocated
memory and does not need to be explicitly freed.

This closes java-native-access#867
@matthiasblaesing matthiasblaesing merged commit fa6cb7e into java-native-access:master Oct 30, 2017
@matthiasblaesing matthiasblaesing deleted the com_memory_leak_string_property branch November 5, 2017 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

COMLateBindingObject#getStringProperty leaks memory

1 participant