Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Why MarshalledObject does not free native memory even though disposing? #85

Description

@dngs365

I felt the design of structs are bad. But I can understand that because there is so many arrays to be flat memory.
However, memory leaking is another context.

I wondered that why samples are not dispose any of IDisposables such like infos.
I got the NativeReference handle this and it frees the native memory when destructed.
But, as you know, the destructor and finalizer are not guaranteed to be called.

Therefore we must call the Dispose() manually.
But NativeReference is a internal class.
So we have to call MarshalledObject.Dispose() instead which is public.
BTW, it dose not calling NativeReference.Dispose() at all.
It also leave it to destructor.

In the end, there is no chance to guarantee to prevent memory leaking.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions