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

java.lang.OutOfMemoryError:Unable to read large file #201

Open
Joanh731 opened this issue Aug 8, 2023 · 0 comments
Open

java.lang.OutOfMemoryError:Unable to read large file #201

Joanh731 opened this issue Aug 8, 2023 · 0 comments

Comments

@Joanh731
Copy link

Joanh731 commented Aug 8, 2023

Unable to read a 28m file

When it go the "Mp3File mp3File = new Mp3File(path);" and the file's size out of 28m,it will throw the OutOfMemoryError

java.lang.OutOfMemoryError: Failed to allocate a 29770255 byte allocation with 6291456 free bytes and 16MB until OOM, max allowed footprint 39725816, growth limit 50331648
                                                                                                    	at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                                                                                    	at java.nio.DirectByteBuffer$MemoryRef.<init>(DirectByteBuffer.java:71)
                                                                                                    	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:240)
                                                                                                    	at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:168)
                                                                                                    	at sun.nio.ch.IOUtil.read(IOUtil.java:195)
                                                                                                    	at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:187)
                                                                                                    	at com.mpatric.mp3agic.Mp3File.initCustomTag(Mp3File.java:313)
                                                                                                    	at com.mpatric.mp3agic.Mp3File.init(Mp3File.java:101)
                                                                                                    	at com.mpatric.mp3agic.Mp3File.<init>(Mp3File.java:58)
                                                                                                    	at com.mpatric.mp3agic.Mp3File.<init>(Mp3File.java:45)
                                                                                                    	at com.acloud.stub.localmusic.QtActivity.getMp3bytes(QtActivity.java:1522)
                                                                                                    	at com.acloud.stub.localmusic.QtActivity.lambda$loadArtistImageWithSongPath$1$QtActivity(QtActivity.java:1502)
                                                                                                    	at com.acloud.stub.localmusic.-$$Lambda$QtActivity$zqAHJFCvZ72ENomoa5ol6UnlrjE.run(Unknown Source:4)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                                                                                                    	at java.lang.Thread.run(Thread.java:764)
private static byte[] getMp3bytes(String path) {
        byte[] b = null;
        Log.d(TAG, "getMp3bytes: =====path==>" + path);
        try {
            Mp3File mp3File = new Mp3File(path);
            if (mp3File.hasId3v2Tag()) {
                b = mp3File.getId3v2Tag().getAlbumImage();
                if (b != null)
                    Log.d(TAG, "getMp3bytes: =======getMp3_pic_bytes_size==>" + b.length);
            }
        } catch (IOException | UnsupportedTagException | InvalidDataException |
                 IllegalArgumentException | OutOfMemoryError e) {
            Log.e(TAG, "getMp3bytes: ", e);
        }
        return b;
    }
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

No branches or pull requests

1 participant