GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — How to clean up memory of a song in order to load the next one · Issue #76 · processing/processing-sound

How to clean up memory of a song in order to load the next one #76

New issue
Copy link
New issue
Copy link
Open
Open
How to clean up memory of a song in order to load the next one#76
Copy link
Labels
Android

Description

@bigboss97
bigboss97
opened on Dec 19, 2022
Issue body actions

I'm using Processing 4.1.1 in Android mode. I've downloaded the latest library from here and it works much better than the built-in one. Now I can open larger song and run it in correct speed. Thanks for the fix.

I'm currently facing an issue. I can't load next song because it runs out of memory. I tried to use removeFromCache(), assign null to my SoundFile and do System.gc(). Nothing helped.

My question, is there a way to force a memory release before I create the next SoundFile?

Activity

  1. kevinstadler commented on Dec 20, 2022

    @kevinstadler
    kevinstadler
    on Dec 20, 2022
    Collaborator
    More actions

    Thanks for your report, could you maybe try downloading this library test build (just extract it into your Arduino/libraries folder) and make sure you explicitly call firstfile.stop() before all of your other garbage collection steps and let me know if that helps? The same gc issue is what underlies #74 so it would be great to get some grip on this...

  2. bigboss97 commented on Dec 21, 2022

    @bigboss97
    bigboss97
    on Dec 21, 2022
    Author
    More actions

    Thanks for your quick response. I've created following test sketch and it worked great:

    import android.os.Environment;
    import processing.sound.*;
    
    final String androidRoot= new String( Environment.getExternalStorageDirectory().getAbsolutePath());
    SoundFile music;
    String song1= androidRoot+"/myHome/Music/English/Beat it - Michael Jackson.mp3";
    String song2= androidRoot+"/myHome/Music/English/Beep - The Pussycat Dolls.mp3";
    
    
    void setup() {
      while( true) {
        println("Load 1");
        music= new SoundFile( this, song1);
        music.play();
        println("Playing 1");
        delay(5000);
        
        music.stop();
        music.removeFromCache();
        music= null;
        println("Cleaned 1");
        
        println("Load 2");
        music= new SoundFile( this, song2);
        music.play();
        println("Playing 2");
        delay(5000);
        
        music.stop();
        music.removeFromCache();
        music= null;
        println("Cleaned 2");
      }
    }
    

    Unfortunately, it's still crashing in my program. I guess it's because of the variable scope. I use the SoundFile in a class. Maybe it doesn't get cleaned up as long as the object is still around. I'll work around this and use a global variable.

  3. trackme518 commented on Dec 8, 2023

    @trackme518
    trackme518
    on Dec 8, 2023
    More actions

    Hi,
    I have: similar issue

  4. kevinstadler
    added
    Android
    on Dec 9, 2023
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

    Android

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.