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

Bugfix/memory leak #52

Open
wants to merge 4 commits into
base: sgpd_versions
Choose a base branch
from

Conversation

ohjiwoo123
Copy link

First, Solved Memory Leak in traf (MP4TrackFragmentAtom)
Second, Solved Memory Leak in trex (MP4TrackExtendsAtom)

If user makes Fragment Mp4, There are some memory leak.
There is no memory free for MP4TrackFragmentAtom.
There is no memory free for MP4TrackExtendsAtom.

After add Code and completing the test, There is no memory leak.

@podborski
Copy link
Member

Thanks, there seem to be a problem with the compilation on linux and some basic clang-format issues.

@ohjiwoo123
Copy link
Author

ohjiwoo123 commented Dec 13, 2023

Complete the Change Formatting with clang-format.
Could you try again?
Thank you.

@ohjiwoo123 ohjiwoo123 closed this Dec 13, 2023
@ohjiwoo123 ohjiwoo123 reopened this Dec 13, 2023
@ohjiwoo123
Copy link
Author

Do I must use formatting clang-format vesion 13 ? ( as written in isobmff/.github/workflows/clang-format.yml )
I am formatting file with clang-format version 18.0.0

@ohjiwoo123
Copy link
Author

ohjiwoo123 commented Dec 15, 2023

I think that you need to change the clang-format.yml file (version up)
If I use jidicula/[email protected] version, The error raised like below.

Installing clang-format-13
E: Unable to locate package clang-format-13
Not a directory in the workspace, fallback to all files.
/entrypoint.sh: line 23: /usr/bin/clang-format-13: No such file or directory

https://github.com/MPEGGroup/isobmff/blob/master/.github/workflows/clang-format.yml

jidicula/[email protected] -> jidicula/[email protected]
or
jidicula/[email protected]
Thank you

@podborski
Copy link
Member

Yep, I remember we fixed some of those issues in the sgpd_versions branch. It now has a lot of useful changes in it. I suggest we merge this one to that branch as well.

@podborski podborski changed the base branch from master to sgpd_versions January 3, 2024 01:07
err = MP4GetListEntry(moof->atomList, i, (char **)&traf);
if(err) goto bail;
traf->destroy((MP4AtomPtr)traf);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not so sure about this one. Below moof->destroy is called which should already do this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this library's design and understand what you said.
But, If there is no below code

for(i = 0; i < moof->atomList->entryCount; i++)
    {
      err = MP4GetListEntry(moof->atomList, i, (char **)&traf);
      if(err) goto bail;
      traf->destroy((MP4AtomPtr)traf);
    }

traf is still in memory.

If this code is not matching this library design,
you need to check moof destory's flow.

@@ -34,7 +34,8 @@ static void destroy(MP4AtomPtr s)

self = (MP4MovieFragmentAtomPtr)s;
if(self == NULL) BAILWITHERROR(MP4BadParamErr)
DESTROY_ATOM_LIST_F(atomList);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this part child boxes are destroyed which should also include the traf box that you destroy manually in MP4MovieFile.c

@@ -34,7 +34,8 @@ static void destroy(MP4AtomPtr s)

self = (MP4MovieFragmentAtomPtr)s;
if(self == NULL) BAILWITHERROR(MP4BadParamErr)
DESTROY_ATOM_LIST_F(atomList);
err = MP4DeleteLinkedList(self->atomList);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already a part of the macro above.

Copy link
Author

@ohjiwoo123 ohjiwoo123 Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In side of Macro code

#define DESTROY_ATOM_LIST                                      \
  if(self->atomList)                                           \
  {                                                            \
    u32 atomListSize;                                          \
    err = MP4GetListEntryCount(self->atomList, &atomListSize); \
    if(err) goto bail;                                         \
    for(i = 0; i < atomListSize; i++)                          \
    {                                                          \
      MP4AtomPtr a;                                            \
      err = MP4GetListEntry(self->atomList, i, (char **)&a);   \
      if(err) goto bail;                                       \
      if(a) a->destroy(a);                                     \
    }                                                          \
    err = MP4DeleteLinkedList(self->atomList);                 \
    if(err) goto bail;                                         \
  }

if(a) a->destroy(a);
err = MP4DeleteLinkedList(self->atomList);
I think that those free the memory same thing
Is it Right or not ?

My Thought is we use only err = MP4DeleteLinkedList(self->atomList);
for free the self->atomList memory.

I do not understand LinkedList have several ListEntry and several entry count.

I add this code due to 'Segmentation Fault Error Raised'
when I free the MP4MovieFragmentAtomPtr

}
}
}

if(moov->moovAtomPtr) moov->moovAtomPtr->destroy(moov->moovAtomPtr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the above not already handled by this call?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If It makes movie atom for fragment mode,
It need to free the memory traf atom and trex atom.

if(moov->moovAtomPtr) moov->moovAtomPtr->destroy(moov->moovAtomPtr);

This part do not free the memory of atoms derived from fragments

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.

2 participants