Listing all Blobs in the memory for debugging in javascript
Asked Answered
P

2

7

If I create multiple new blobs:

var myBlob1 = new Blob(['Hello world!'], {type: 'text/plain'});
var myBlob2 = new Blob(['Very cool!'], {type: 'text/plain'});
var myBlob3 = new Blob(['I love AI!'], {type: 'text/plain'});

How can I list them all in Chrome Dev Tools (or in plain javascript) to expose all the blobs and get all the information? So the result I'm requiring is somehow:

var blobs = getBlobs(); // [myBlob1, myBlob2, myBlob3]
Piping answered 6/3, 2019 at 15:47 Comment(5)
You create one new blob - but what to list them all? Please clarify.Wetnurse
For debugging, so if I were to get video data from a site that uses blobs, I want to know how to list all the blobs that are used and get the information from that blobPiping
@RandyCasburn I clarified a bit more nowPiping
Still confused. If you are creating them, and you need to access the collection of them later, it seems the logical solution is to put them into the collection at the time of creation: let blobCollection = []; blobCollection.push(new Blob(['Sup?']), {type: 'text/plain'});Wetnurse
My question is to get the list of blobs, without the use of intentionally storing, my point is to list all the blobs used by a websitePiping
K
8

I found this question while looking for this very URL I knew existed but had forgotten, it's hard to find documentation for it.

When using Chrome you can access chrome://blob-internals/ which lists all Blobs URLs that have been created. It doesn't provide a nice interface like dev tools, but it should help you track whether you are revoking URLs appropriately.

Kimberli answered 17/1, 2021 at 10:1 Comment(0)
I
1

You can try to take a Memory Snapshot from your dev-tools, and then to filter by class using Blob.
From there, you should have a list of all the Blobs that were in memory when you ran the Snapshot.
But you won't have much information on these Blobs, even their number might be off.

And there is no way to have it from web-APIs, if there was such a method, then browsers couldn't collect it when unused.

Inchon answered 12/3, 2019 at 8:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.