Program for a museum using video and sound library

Hello @rociodp,

Try VisualVM:

Try to determine when the memory increases.
There is a learning curve to using this but worthwhile.

This is a homework question in a public forum so be mindful of what you are posting and sharing:
https://discourse.processing.org/faq#homework

Try to work out the memory problems separately from you code with an MCVE:

Your posted code had a missing bracket.

:)