How do I do End Layout?

1 favourites
  • Is there a specific End Layout function? Or does going to a different Layout end the current Layout? When a different layout is displayed, does the previous layout that is no longer displayed still persisting? Or does the act of a second layout being displayed end the previous layout?

  • Phoenixbowman Don't be stressed about it. Construct 2 is smart enough to flush out memory of images from past layout to make room for another layout.

    Please read if you have time : (These are helpful and this is from the founder of Construct 2 "Ashley")

    https://www.scirra.com/tutorials/298/pe ... bile-games

    https://www.scirra.com/blog/83/optimisa ... -your-time

    https://www.scirra.com/manual/134/performance-tips

  • Something is causing memory to keep increasing. The memory goes up and up. If objects were being flushed than memory would drop. Something is still running in previous layouts. I re-use Sprites from previous layouts.

    Do Sprites that are used later persist in memory from previous layouts?

  • My FPS is steady. The game runs smoothly, so it's not too many sprites on the screen.

  • Something is causing memory to keep increasing. The memory goes up and up. If objects were being flushed than memory would drop. Something is still running in previous layouts. I re-use Sprites from previous layouts.

    Do Sprites that are used later persist in memory from previous layouts?

    In my past experiments. There are some cases.

    If the sprites from your old layout is present in your new layout then it won't be flushed but if it isn't present in the next layout then it will be flushed.

    If the sprites are global then it will never be flushed.

    -------------------------------------------------------------

    //*Persistent Sprites - Don't be fooled of the word, the image is not stored in the memory. The information that it exists is stored in the storage of the device if I am correct.*//

    If the sprites are persistent then the information that it exists is stored in the storage of the device(Not MEMORY).

    So the memory management is still the same above but better optimized because the if the image is not preloaded in the layout but when you are back in the layout

    it automatically preloads itself. But on initial creation, it should be preloaded by adding the object in the layout on startup and destroyed if not needed.

  • > Something is causing memory to keep increasing. The memory goes up and up. If objects were being flushed than memory would drop. Something is still running in previous layouts. I re-use Sprites from previous layouts.

    >

    > Do Sprites that are used later persist in memory from previous layouts?

    >

    In my past experiments. There are some cases.

    If the sprites from your old layout is present in your new layout then it won't be flushed but if it isn't present in the next layout then it will be flushed.

    The Sprites from the old layout are present in the new layout.

    Thank you for this information. That could explain what is going on.

    Will doing at End of Layout > Destroy A destroy the sprite and flush it from memory?

    On End of Layout > Destroy A

    Destroy B

    Destroy C

    A B C and are on the current layout. Will that function destroy A B and C, even if they are present on the next layout?

  • As in, A B and C are present on the current layout. WIll the End of Layout Destroy function flush them from memory, even if they are present on the next layout?

    So they're flushed from memory, so they don't keep piling up. That way, they're only present in memory when on the active layout. So there are not instances of them still existing from previous layouts.

  • There ought to be a function that checks to see if Sprites are used on the next layout. If they are, then there should be the option to flush them from memory. That way, they're not piling up.

  • >

    > > Something is causing memory to keep increasing. The memory goes up and up. If objects were being flushed than memory would drop. Something is still running in previous layouts. I re-use Sprites from previous layouts.

    > >

    > > Do Sprites that are used later persist in memory from previous layouts?

    > >

    >

    > In my past experiments. There are some cases.

    >

    > If the sprites from your old layout is present in your new layout then it won't be flushed but if it isn't present in the next layout then it will be flushed.

    >

    The Sprites from the old layout are present in the new layout.

    Thank you for this information. That could explain what is going on.

    Will doing at End of Layout > Destroy A destroy the sprite and flush it from memory?

    On End of Layout > Destroy A

    Destroy B

    Destroy C

    A B C and are on the current layout. Will that function destroy A B and C, even if they are present on the next layout?

    I think you misunderstood something Phoenixbowman .

    The images of the sprite are the only thing stored in the memory not the sprites or objects nor instances. The instances you are talking about (The Objects on the layout, THE number of sprites) are codes that are generated by the things you put in the layout or you created using the eventsheet.

    IE: 100 instances of 1 sprite of 32x32 image

    (100 instances are code during layout and not persisted on next layout in other words they are only available in that layout and is cpu based not memory.)

    (1 sprite of 32x32 image is stored in the memory)

    Explanation:

    1 image of 32x32 image or frame is stored in the memory and the cpu is used to make them 100 instances and do movements.

  • Going from a layout to another one, instances are deleted, but the texture for the sprite object stays in memory.

    If you keep piling memory (or memory leak) perhaps do you have some loop in your code that tries to create/destroy objects which could cause such an issue.

    C2 has its own garbage collection so you don't have to worry about this normally, unless you're going against this logic somehow.

    Debug/profile your project to see what may be going on.

  • There ought to be a function that checks to see if Sprites are used on the next layout. If they are, then there should be the option to flush them from memory. That way, they're not piling up.

    Uhhm. Yes and No.

    Actually, Construct 2 adds and flushes images based on what you put inside the layout.

    For example: If I add an image of "Player1" in "Layout1" but did not add it in "Layout2" then If I go from "Layout1" and go to "Layout2" then the memory will flush "Player1" when I go to "Layout2". That is because Construct 2 only preloads or adds images from what Construct 2 sees inside the layout. Thats why if we have an event that will create objects, we need to make sure that the images of the objects are all added in the layout

  • I did read that Ashley tutorial document. Those are general tips. Saying "Read this" doesn't address a specific cause as to why the memory keeps climbing up and up.

    Something is making it go up and up. I read that, and it did not help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Going from a layout to another one, instances are deleted, but the texture for the sprite object stays in memory.

    If you keep piling memory (or memory leak) perhaps do you have some loop in your code that tries to create/destroy objects which could cause such an issue.

    C2 has its own garbage collection so you don't have to worry about this normally, unless you're going against this logic somehow.

    Debug/profile your project to see what may be going on.

    No, no loops in my code that create/destroy objects.

  • Phoenixbowman - Okay I understand. Can you show us a .capx file because guessing will be the only thing we can do without much information.

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