var dict1={}
for i in range(30_000):
dict1[i] = Color.RED
var dict2={}
for i in range(40_000):
dict2[i] = Color.RED
dict1 works as intended but dict2 becomes null. So this is most likely a memory issue? I’m not 100% certain. Why is this happening and how can I fix it? (If i even can)
A lot of thing will happen before memory runs out. On windows a “page” file will be written to disk as a super-slow version of ram; similarly on linux a “swap” partition, file, or compression depending on the set up. Generally your operating system will kill programs before acknowledging it’s out of ram.
I’ve bumped it to one million colors is dict2
func _ready() -> void:
var dict1={}
for i in range(30_000):
dict1[i] = Color.BLUE
var dict2={}
for i in range(1_000_000):
dict2[i] = Color.RED
print(var_to_bytes(dict2).size()) # 28000008
print(dict1[200]) # (0, 0, 1, 1)
print(dict2[1_000]) # (1, 0, 0, 1)
The prints indicate a dictionary of 1 million colors uses about 28MB, I’m sure it’s a bit off but it’s far from eating up all of your system memory.