Discuss Scratch

Chiroyce
Scratcher
1000+ posts

Improve Scratch's memory management.

TL;DR
A single tab trying to load a Scratch project used up 14GB of RAM, so Scratch's memory management has to be improved.
______

Since a long time, loading scratch projects that have a lot of assets are very heave in terms of memory, here is an example –

I tried loading a project on my 2.5 month old laptop (MacBook Air, M1). It has 16 GIGABYTES of RAM, which is nearly twice as much as the average amount of memory Scratchers have (8), and some may even be using 4GB of RAM, or mobile devices with even 2!

https://scratch.mit.edu/projects/46130596/ is a project, which, I'm not lying, when I tried loading it, it used up 14 GIGABYTES of RAM, which is INSANE for a Scratch project, I know that it may have a lot of assets, but 14 is so much that my Mac instantly told me that it was running out of memory, and closing this tab may improve responsiveness.

It also had to utilize the SSD for memory, about 3GB of what had to be written to memory, was written to the SSD, and a lot of Scratchers still use HDDs (hard disks), which means their devices would become insanely slow trying to use 3GB of HDD as memory. I restarted my laptop, fresh and clean with no apps open, I open up my default browser (Safari), and I try loading this project, the same thing happens! 14 GIGABYTES of RAM was being used up by this individual tab, excluding the OSs memory!

16 GIGABYTES of RAM isn't what the average Scratcher has, as I said earlier, some may even be using 2 or 4. So can the devs, somehow improve memory management of Scratch projects? A Scratch project using up 14GB of RAM with no other programs/apps/tabs/browsers open (and without looking at how much the OS is using), is not a small thing, this has to be fixed. A lot of projects like these exist, instead of doing something to the projects, somehow can you try to improve how the scratch-gui / vm handles these big projects?

Now I know, you must be thinking,
“Chiroyce, there might be many assets in that project, that's the reason, we can't do anything about it!”,
well yes, but we have to do something, like compress assets or something. Please address this issue ASAP.

Vadik1 wrote:

The thing you haven't mentiond is how forkphorus has a really good memory usage. Using forkphorus I'm able to load and view that project without any issues on a phone which when no apps are running on average has 2 gb of free ram.
Wow! It literally only used about 700MB of RAM on forkphrous, thanks for letting me know! TurboWarp is still the same though, does anyone know why?

Last edited by Chiroyce (April 18, 2022 15:49:18)








April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
gdpr5b78aa4361827f5c2a08d700
Scratcher
1000+ posts

Improve Scratch's memory management.

support, this is actually ridiculous, and scratch's current system is a terrible way of handling assets in memory. it would be better to load and unload assets as they're needed, similar to how unity, unreal, or pretty much any respectable game engine out them. this might take a bit of work, but it really should be done since this kind of thing is pretty much essential for something like this.
Vadik1
Scratcher
500+ posts

Improve Scratch's memory management.

Support.
The thing you haven't mentiond is how forkphorus has a really good memory usage. Using forkphorus I'm able to load and view that project without any issues on a phone which when no apps are running on average has 2 gb of free ram.

Last edited by Vadik1 (June 19, 2021 15:07:17)


I mostly make 3D projects. Here are some of them:

kccuber
Scratcher
1000+ posts

Improve Scratch's memory management.

Chiroyce wrote:

which is nearly twice as much as the average amount of memory Scratchers have (8)
jokes on you i have 48 GB of RAM
—-
I support as this is literally ridiculous. 14 GB??? Something is wrong with Scratch, and it seems like this would literally crash my iPad.


Made using Nord Theme & Inkscape
Chiroyce
Scratcher
1000+ posts

Improve Scratch's memory management.

Vadik1 wrote:

Support.
The thing you haven't mentiond is how forkphorus has a really good memory usage. Using forkphorus I'm able to load and view that project without any issues on a phone which when no apps are running on average has 2 gb of free ram.
Wow! It literally only used about 700MB of RAM, thanks for letting me know! TurboWarp is still the same though, does anyone know why?

kccuber wrote:

I support as this is literally ridiculous. 14 GB??? Something is wrong with Scratch, and it seems like this would literally crash my iPad.
Not really, Safari for iPadOS automatically closes tabs that take too much memory, no matter how much you try, it simply won't load the project. I do NOT know about Chrome though… but still, it's dangerous.

Last edited by Chiroyce (June 19, 2021 16:04:32)








April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
nampinanathali
Scratcher
1000+ posts

Improve Scratch's memory management.

Chiroyce wrote:

Vadik1 wrote:

Support.
The thing you haven't mentiond is how forkphorus has a really good memory usage. Using forkphorus I'm able to load and view that project without any issues on a phone which when no apps are running on average has 2 gb of free ram.
Wow! It literally only used about 700MB of RAM, thanks for letting me know! TurboWarp is still the same though, does anyone know why?

kccuber wrote:

I support as this is literally ridiculous. 14 GB??? Something is wrong with Scratch, and it seems like this would literally crash my iPad.
Not really, Safari for iPadOS automatically closes tabs that take too much memory, no matter how much you try, it simply won't load the project. I do NOT know about Chrome though… but still, it's dangerous.


google chrome on ipad do the same thing.

mom when look at my browser history
ScratchCatHELLO
Scratcher
1000+ posts

Improve Scratch's memory management.

support, scratch froze my computer at one point (actually, the tab was turbowarp, but still)

Chiroyce wrote:

twice as much as the average amount of memory Scratchers have (8)

jokes on you I have 15.4 Gibibytes of dedotated wam RAM or something





ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust



Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
D-ScratchNinja
Scratcher
1000+ posts

Improve Scratch's memory management.

Scratch should definitely try to unload things it isn't rendering when your device runs low of memory at least. Frame-by-frame animations are basically unwatchable on devices with little RAM.

D-ScratchNinja • he/him
- The following is my signature, which always shows up below my posts. -


New! Filter through my projects with my website.

Need to fix an issue? Check out this studio for solutions to some common problems!

OS: Windows 11 / Browser: Microsoft Edge / Time zone: PST/PDT
Raihan142857
Scratcher
1000+ posts

Improve Scratch's memory management.

I have 4 GB of RAM and things were getting really crazy really fast so I closed the tab on that project.
Who knows what would have happened to by laptop if I hadn't, (and who knows what has already happened to other people's computers), so I support.

I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?










gdpr5b78aa4361827f5c2a08d700
Scratcher
1000+ posts

Improve Scratch's memory management.

Raihan142857 wrote:

Who knows what would have happened to by laptop if I hadn't
house fire.
Raihan142857
Scratcher
1000+ posts

Improve Scratch's memory management.

potatophant wrote:

Raihan142857 wrote:

Who knows what would have happened to by laptop if I hadn't
house fire.
I have 4 GB of RAM and 3.6 GB of free disk space. It took Chiroyce 14 GB of RAM for the project to load. I am honestly quite interested in what could happen (either something mundane will happen, like my computer restarting, or something crazy can happen) but I don't want to risk it.

I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?










Chiroyce
Scratcher
1000+ posts

Improve Scratch's memory management.

Raihan142857 wrote:

I have 4 GB of RAM and 3.6 GB of free disk space. It took Chiroyce 14 GB of RAM for the project to load. I am honestly quite interested in what could happen (either something mundane will happen, like my computer restarting, or something crazy can happen) but I don't want to risk it.
Here is me risking it -

Raihan142857 wrote:

I have 4 GB of RAM and 3.6 GB of free disk space. It took Chiroyce 14 GB of RAM for the project to load. I am honestly quite interested in what could happen (either something mundane will happen, like my computer restarting, or something crazy can happen) but I don't want to risk it.
You would've gotten a Blue Screen on Windows or a kernel panic on macOS/Linux because

Chiroyce wrote:

It also had to utilize the SSD for memory, about 3GB of what had to be written to memory, was written to the SSD, and a lot of Scratchers still use HDDs (hard disks), which means their devices would become insanely slow trying to use 3GB of HDD as memory.







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
dhuls
Scratcher
1000+ posts

Improve Scratch's memory management.

Here is why(?) Forkphorus uses so little memory compared to Turbowarp:
Forkphorus is based off of Phosphorus, which was an HTML5 Player for Scratch 2.0 projects. Forkphorus simply added support for Scratch 3.0 projects. Phosphorus was probably designed to not use a lot of RAM, something that the ST probably overlooked when developing Scratch 3.0. Turbowarp, being based off of Scratch 3.0 for more compatibility instead of Forkphorus, still suffers from the high amount of memory that Scratch 3.0 has.

Support. I don't want my PC to die. If someone with an (almost) brand new Macbook with 16GB of RAM and an M1 SoC has issues, my Surface Book with an 8th gen Intel Core chip will probably get bricked.

Last edited by dhuls (June 20, 2021 05:40:14)

Chiroyce
Scratcher
1000+ posts

Improve Scratch's memory management.

dhuls wrote:

Phosphorus was probably designed to not use a lot of RAM, something that the ST probably overlooked when developing Scratch 3.0.
So the ST should fix it, right?







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
fdreerf
Scratcher
1000+ posts

Improve Scratch's memory management.

Chiroyce wrote:

dhuls wrote:

Phosphorus was probably designed to not use a lot of RAM, something that the ST probably overlooked when developing Scratch 3.0.
So the ST should fix it, right?
I'm not sure if that's possible, since the comparison between Scratch and Forkphorus/Turbowarp isn't fair. Scratch converts Scratch code into Javascript on the fly, whereas Turbowarp compiles first. I'm not an expert in these sorts of things but I think that reduces memory usage by a lot.

Last edited by fdreerf (June 20, 2021 06:14:15)


Hyped for MS-DOS 11.0
Socialix
Scratcher
1000+ posts

Improve Scratch's memory management.

Support, because apparently iPhones and iPads are too optimized to have RAM and high-ram devices are way too expensive nowadays (atleast for turkey).

socialix - why is there a penguin breaking my window? - signatures are overrated
linearlemur
Scratcher
500+ posts

Improve Scratch's memory management.

Support, I have 8 GB of RAM (More like 7.9 GB but still) and Chrome just crashed, it straight up crashed.

I found out how to put letters in cloud variables! https://turbowarp.org/526557379 (I really didn't feel like sharing the project, lol)
quasarNebula
Scratcher
77 posts

Improve Scratch's memory management.

potatophant wrote:

support, this is actually ridiculous, and scratch's current system is a terrible way of handling assets in memory. it would be better to load and unload assets as they're needed, similar to how unity, unreal, or pretty much any respectable game engine out them. this might take a bit of work, but it really should be done since this kind of thing is pretty much essential for something like this.
This would go a long way in reducing the load of assets on RAM, but—and take this with a grain of salt because I really have no experience with any of these game engines :P—is there actually any way to predict which assets will be required soon, so they can be preloaded? I'm pretty sure the reason Scratch keeps all those assets in memory at all times is so that they can be used immediately, without any delay, which is pretty important for most projects.

Most games use loading screens or otherwise dynamic loading in order to load assets without interrupting gameplay, and they can do that because they know exactly which assets are going to be needed soon… but I can't think of how the Scratch language would detect that itself, which it would need for its own dynamic loading. Depending on the user to explicitly say which assets need to be loaded is obviously too complicated and impractical for most Scratchers, but I can't think of what another solution would be!

~QN // we swap between using this account and @_nix pretty much at random lol, but they're both us!
Chiroyce
Scratcher
1000+ posts

Improve Scratch's memory management.

bump







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
dhuls
Scratcher
1000+ posts

Powered by DjangoBB