While Condition causing a Memory Leak

0 favourites
  • 5 posts
From the Asset Store
Test and challenge your memory in this amazing Christmas themed memory game!
  • Problem Description

    When the While condition is triggered, the tab freezes and the browser quickly allocates memory continously.

    Attach a Capx

    https://drive.google.com/open?id=15CaEM ... z33Q54Dz0k

    Description of Capx

    Quickly triggers the While condition which runs a "Wait 1 second" action, while a sprite's 2-frame animation works in the background.

    Steps to Reproduce Bug

    • Insert the While condition somewhere where it can be triggered
    • Add an action for the While condition to run (It can be anything)

    Observed Result

    Nothing shows up, and memory is quickly taken up (at a rate of 200-300MB) until forcefully closed by Task Manager or the computer freezes.

    Expected Result

    The sprite in the window should flash between two colours.

    Affected Browsers

    • Chrome: YES
    • FireFox: N/A
    • Internet Explorer: YES
    • Edge: YES

    Operating System and Service Pack

    Windows 10

    Construct 2 Version ID

    Release 249

    Notice: Have Task Manager ready to close the browser, or risk a computer crash. Make sure all work is saved and closed, in case Task Manager cannot close the browser.

  • Well, of course an infinite loop is gonna crash the system.

    And the "Wait 1 second" action is creating thousands upon thousands of "contexts" from which execution would resume from, and all that overhead needs memory... and looks like it needs a lot of it.

    Absolutely not a bug, it's something you should never do, like dividing by zero.

  • Well, of course an infinite loop is gonna crash the system.

    And the "Wait 1 second" action is creating thousands upon thousands of "contexts" from which execution would resume from, and all that overhead needs memory... and looks like it needs a lot of it.

    Absolutely not a bug, it's something you should never do, like dividing by zero.

    I actually found it while creating something that supposedly isn't in a loop, and couldn't find the reason why it kept looping.

    In my work, the While condition was supposed to stop once a local variable reached under 1, which would be caused by a subtract action which was being repeated by the condition.

    I have now found my issue: Just like with Repeat, the While condition does not wait for the last loop to finish. The command that basically stops the loop occurs after a delay, which means there's a lot of time for other loops to start.

    Looks like there isn't any bug to see here. Thank you for reminding me of that.

    Though this kind of problem means anyone can crash someone else's computer in a game, so long as there's not a lot of memory to take before the user notices and attempts closing the browser.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This is a common mistake. Loops and waits don't go well together. It *can* be useful to do a small amount of "repeats", combined with a "Wait loopindex * delayBetweenLoops"... that creates some kind of pseudo delayed loop execution.

  • You just made an infinite loop. Closing as not a bug.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)