Android [SOLVED] Local variables disappear

V

Vladislav

Guest
Hi, guys

After a pause, some variables disappear and the game crashes. The most interesting thing is that this does not happen all the time, but about 1 out of 5 times.
Pause done with functions: instance_deactivate(all); instance_activate_all()

What could be the problem?
 
D

Danei

Guest
Oh. Is that a good thing? What instance is running the instance activation?
 

Gradius

Member
I'm assuming you mean 'instance' variables, as 'local' variables (created with the 'var' keyword) only exist within the code or script they're set in and never carry over.

That said, a few questions:

1. Are you creating/setting your variables in the Create event of your objects?

2. Is the non-existant variable being accessed within the same instance or by another instance?

That might help narrow down why your code is behaving strangely. Also might not hurt to clear your cache (hit the paint brush icon), as that can sometimes solve with code behaving badly.
 
V

Vladislav

Guest
I'm assuming you mean 'instance' variables, as 'local' variables (created with the 'var' keyword) only exist within the code or script they're set in and never carry over.

That said, a few questions:

1. Are you creating/setting your variables in the Create event of your objects?

2. Is the non-existant variable being accessed within the same instance or by another instance?

That might help narrow down why your code is behaving strangely. Also might not hurt to clear your cache (hit the paint brush icon), as that can sometimes solve with code behaving badly.
Yes, mb its instance variable
I'm creating it in "Create event"

upload_2018-12-15_23-27-39.png
 
V

Vladislav

Guest
I'm assuming you mean 'instance' variables, as 'local' variables (created with the 'var' keyword) only exist within the code or script they're set in and never carry over.

That said, a few questions:

1. Are you creating/setting your variables in the Create event of your objects?

2. Is the non-existant variable being accessed within the same instance or by another instance?

That might help narrow down why your code is behaving strangely. Also might not hurt to clear your cache (hit the paint brush icon), as that can sometimes solve with code behaving badly.
It seems that I found the problem, but I do not know what the reason is.
After a pause, the memory used is constantly increasing.
Maybe for this reason there are failures?
 

Relic

Member
Look for reasons why surfaces, data structures, particle systems (things you should clear from memory when not required) would keep being created during your pause effect. Double check memory increases only during the pause effect too and it’s not just a coincidence that when you pause is when the crash happens (since you say it is random)
 
V

Vladislav

Guest
Look for reasons why surfaces, data structures, particle systems (things you should clear from memory when not required) would keep being created during your pause effect. Double check memory increases only during the pause effect too and it’s not just a coincidence that when you pause is when the crash happens (since you say it is random)
Found a problem. When I paused, I created a screen and saved it to the background, but did not delete it. And so the memory constantly increased and this led to failures. Thanks to everyone who responded)
 
Top