Discuss Scratch

cool_boy_007
Scratcher
1 post

Scratch crashes when i use this code

My browser / operating system: Windows NT 10.0, Chrome 129.0.0.0, No Flash version detected

Scratch hangs and crashes when i use this code. Why?
event->start as a clone
step->create a clone of myself
step->delete this clone

Last edited by cool_boy_007 (Oct. 15, 2024 22:10:12)

blubby4
Scratcher
100+ posts

Scratch crashes when i use this code

This is a very well known script that freezes the scratch interpreter. Presumably it's because creating the clone runs the script immediately? [citation needed] and the JS gets stuck in an infinite loop.

I think about things. Sometimes I think about things too much, and miss obvious simple things
ihavenocluewhythisis
Scratcher
100+ posts

Scratch crashes when i use this code

blubby4 wrote:

This is a very well known script that freezes the scratch interpreter. Presumably it's because creating the clone runs the script immediately? [citation needed] and the JS gets stuck in an infinite loop.
hey! you forgot how to do a [citation needed]. you need the link.

(‎‎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎[#FFFFFF]‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎::variables)
check out my pixel collection!
dominoes __////////llllllllllllllllllllllllllllll
highlight this and do shift and down to see all signature.
block army:

this is cloop: :: hat
cloop :| {(wood kumquat :: events)} :: grey
idk why a kumquat can fit like that but yeah
also they dissolve kumquats
this is cloner:
cloner :c {} output clone {} :: variables
they can clone cloop, is just that no evil kumquats came. :: cap
I STILL have never seen an evil kumquat in my LIFE (or have I?)
signature-inside-a-signature™
materials:
leaves :: operators
leaves (non-evil kumquat) :: operators
(non-evil kumquat) leaves :: operators
wood :: events
wood :: events
wood :: events
wood :: events cap
wood kumqaut factory:
adder::operators hat
import stuff from above {( non-evil kumquat :: variables)} + {wood :: events cap} = {(wood kumquat :: events)} send result to outside ::operators cap
block painter :: control hat
insert materials here <2 items found, color they will make : (::control) :: grey> {bleach :: grey cap
(non-evil kumquat)}template <{if<boolean>then{…}else{…}::control} found::grey> {if <> then
else
end}block to be painted {if <> then {} else {} :: grey} ::control cap
8to16
Scratcher
1000+ posts

Scratch crashes when i use this code

ihavenocluewhythisis wrote:

hey! you forgot how to do a [citation needed]. you need the link.
not here tho, you only link to the references page on the scratch wiki

ALL POSTS FOLLOWING THIS ONE MUST NOT BE OFF-TOPIC;

anyways this is a really well-known crasher script that is caused by large memory waste.

Last edited by 8to16 (Oct. 16, 2024 14:50:51)


^^^^^ Below this line is a signature. It doesn't have anything to do with the post above.
CST1229
Scratcher
1000+ posts

Scratch crashes when i use this code

8to16 wrote:

(#4)
anyways this is a really well-known crasher script that is caused by recursion. basically when a clone is made, 2 more clones are made, and it keeps going.
Wrong, when running this script there are only a maximum of 2 clones existing at any given moment. It freezes because, like @blubby4 said, “when I start as a clone” blocks run immediately after creating a clone (after the current script pauses/ends), and it gets stuck in an infinite loop.

This is a signature. It's a piece of text that appears below every post I write. Click here to learn more, including how to make your own.

Getting survey popups that look like this? It's normal, and is a thing the ST is doing. Read this topic for more info.




GlitchedThrough
New Scratcher
1000+ posts

Scratch crashes when i use this code

8to16 wrote:

anyways this is a really well-known crasher script that is caused by recursion. basically when a clone is made, 2 more clones are made, and it keeps going.
No, it’s because it quickly uses up your RAM, as writing to it takes priority over removing data. This quickly uses up the RAM allocated to the browser.

Imagine a good signature
Programmer(software developer) and engineer
Proficient in quantum mechanics, classical/Newtonian mechanics, and special/general relativity
blubby4
Scratcher
100+ posts

Scratch crashes when i use this code

GlitchedThrough wrote:

8to16 wrote:

anyways this is a really well-known crasher script that is caused by recursion. basically when a clone is made, 2 more clones are made, and it keeps going.
No, it’s because it quickly uses up your RAM, as writing to it takes priority over removing data. This quickly uses up the RAM allocated to the browser.
No it doesn't. The JS garbage collector can handle it, I tested it a while ago and:

blubby4 a while ago wrote:

…I checked the memory usage before and after triggering the crash blocks, and it went from 77mb to 123mb, but that was in an otherwise blank project
Barely any memory usage. The problem is just that there are no yield points, so the script gets stuck in a loop.

I think about things. Sometimes I think about things too much, and miss obvious simple things
SpyCoderX
Scratcher
1000+ posts

Scratch crashes when i use this code

blubby4 wrote:

GlitchedThrough wrote:

8to16 wrote:

anyways this is a really well-known crasher script that is caused by recursion. basically when a clone is made, 2 more clones are made, and it keeps going.
No, it’s because it quickly uses up your RAM, as writing to it takes priority over removing data. This quickly uses up the RAM allocated to the browser.
No it doesn't. The JS garbage collector can handle it, I tested it a while ago and:

blubby4 a while ago wrote:

…I checked the memory usage before and after triggering the crash blocks, and it went from 77mb to 123mb, but that was in an otherwise blank project
Barely any memory usage. The problem is just that there are no yield points, so the script gets stuck in a loop.
(I can’t test this now) Does the same thing happen if you just run a “while true” loop? If so then you’re probably right.

^ Below this line is my signature ^

New to the forums? Click here!
Want help with your project? Click here!

<Coder | Forum Helper (about)>
You can call me Spy or Spycoder :)

What we need may not be what we want.


Banner by Scratchboxes
blubby4
Scratcher
100+ posts

Scratch crashes when i use this code

SpyCoderX wrote:

blubby4 wrote:

GlitchedThrough wrote:

8to16 wrote:

anyways this is a really well-known crasher script that is caused by recursion. basically when a clone is made, 2 more clones are made, and it keeps going.
No, it’s because it quickly uses up your RAM, as writing to it takes priority over removing data. This quickly uses up the RAM allocated to the browser.
No it doesn't. The JS garbage collector can handle it, I tested it a while ago and:

blubby4 a while ago wrote:

…I checked the memory usage before and after triggering the crash blocks, and it went from 77mb to 123mb, but that was in an otherwise blank project
Barely any memory usage. The problem is just that there are no yield points, so the script gets stuck in a loop.
(I can’t test this now) Does the same thing happen if you just run a “while true” loop? If so then you’re probably right.
What do you mean by “the same thing”? If you mean the page freezing, yes, that happens in an infinite while loop.

I think about things. Sometimes I think about things too much, and miss obvious simple things

Powered by DjangoBB