User Tag List

Results 1 to 9 of 9

Thread: What events or conditions are heavy on memory

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question What events or conditions are heavy on memory

    I have one overall question and a few specific points. I'm looking at optimization and curious what events are potentially heavy on memory usage and should be either avoided or used with caution, particularly for mobile apps.
    I know fastloops are heavy on memory usage.

    1. Are 'For Each' loops faster than fastloops?
    2. Are 'For Each' loops heavy on memory?
    3. Is the 'Always' event heavy on memory (I've heard that it is)?
    4. What other events are potentially heavy on memory and should be handled with care?


    Bear in mind I'm asking in light of maximizing optimization if one had to squeeze every ounce of performance out.
    Thanks
    Simflare

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) Yes, if you've got multiple active objects to loop through. Object selection is sped up exponentially.

    2) Not as heavy as fast loops, by memory I think you mean cpu processing power, because the object selection wouldn't actually keep the object in memory after it's done what it needs to.

    3) You shouldn't use lots of 'always' events, not that it's heavy on memory but that it happens every frame, thats 50 times a second by default. You can optimise by sharing your cpu-heavy events across many frames. Got 60 units that need to follow AI? Rather than have them think every frame, have 20 think on frame 1, 20 think on frame 2, and 20 think on frame 3, then repeat. Your AI doesn't need to have faster-than-human reflexes, the usual human response is 200-400 milliseconds, so a few frames of lag is fine.

    4) Don't be afraid to use fast loops in conjunction with arrays, lists, or other non-active things you need to iterate through. Always put a fast loop in it's own group and run:
    Activate group Myloop
    run loop "Myloop" x amount of times
    Deactivate group Myloop.

    MMF actually needs to do a search on all fast loops to find the right one, but it doesn't search deactivated groups. Not sure if this applies to For Each loops.

  3. #3
    Forum Moderator

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleMac Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)

    Join Date
    Dec 2013
    Location
    Watertown, WI
    Posts
    4,421
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    If an event doesn't need an "Always" , you can replace it with i.e. "Run only once" or "Start of Frame"
    This will reduce a little bit of memory since it's not "Always" scanning for the specific event.

  4. #4
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Pineapple's Avatar
    Join Date
    Oct 2010
    Posts
    431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Checking collision is probably the biggest cause of slowdowns.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    rubes's Avatar
    Join Date
    May 2011
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ryan, thanks for #3, that's a great way to think about things

    3) You shouldn't use lots of 'always' events, not that it's heavy on memory but that it happens every frame, thats 50 times a second by default. You can optimise by sharing your cpu-heavy events across many frames. Got 60 units that need to follow AI? Rather than have them think every frame, have 20 think on frame 1, 20 think on frame 2, and 20 think on frame 3, then repeat. Your AI doesn't need to have faster-than-human reflexes, the usual human response is 200-400 milliseconds, so a few frames of lag is fine.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ryan View Post
    1)

    3) You shouldn't use lots of 'always' events, not that it's heavy on memory but that it happens every frame, thats 50 times a second by default. You can optimise by sharing your cpu-heavy events across many frames. Got 60 units that need to follow AI? Rather than have them think every frame, have 20 think on frame 1, 20 think on frame 2, and 20 think on frame 3, then repeat. Your AI doesn't need to have faster-than-human reflexes, the usual human response is 200-400 milliseconds, so a few frames of lag is fine.
    Thanks for your response, Ryan. How would one separate that over several frames? I understand the logic, but off the top of my head I can't think how I could program it in to events.

    Quote Originally Posted by Perry View Post
    If an event doesn't need an "Always" , you can replace it with i.e. "Run only once" or "Start of Frame"
    This will reduce a little bit of memory since it's not "Always" scanning for the specific event.
    Good point Perry. I do try and find ways to replace "Always" with other events, usually with "If number of objects > 0"

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Create global value currentframe

    Always
    > spread value 0 in enemy alterable value 'ID'
    > set currentframe to currentframe + 1
    > run fast loop 'AI' (Number of Enemies/3) times

    On loop AI
    + ID of enemy = loopindex("AI")+((currentframe mod 3)*(Number of Enemies/3))
    > Do AI for this enemy

    Look up information for the Mod function, there's plenty of info on google about it and this forum. I added extra brackets for comprehension purposes, some can be removed due to order of operations.

    You could also replace the AI loop with a ForEach, maybe you could experiment and see which is faster. How much performance boost you get from this method really depends on how complex your AI is.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Optimization Question

    Ah ok cool thanks.

    Here's another question about optimization, and this one is about scoping.

    Say I have 2 different events to control the hero movement. Event 1 is "walking", Event 2 is "running".

    If I want to check if the hero is running, I could either check if:
    1. the run key is being pressed, or
    2. alterable value "running" is set to 1, aka true


    So in other words, I'm either checking to see if a key is being held down, or if a variable is set to a certain value.

    Which would be quicker to check for, and would either be better in terms of overall optimization? Purely a theoretical debate, not necessarily for this particular application.
    Thanks

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would say the 2nd is slightly worse because you're adding another level of complexity

    If run key is pressed
    > Set running to 1

    If running = 1
    > Do something

    Where you could do:

    If run key is pressed
    > Do something

    But lets say you want to do lots of things when running:

    Yes you could do:
    If run key is pressed
    > Do something

    If run key is pressed
    + Jump key is pressed
    > Do something else

    Or instead you could do:

    If run key is pressed
    > Activate group 'Running'

    Group Running {
    Always
    - Do something
    If jump key is pressed
    - Do something else
    If attack key is pressed
    - Do something awesome
    Always
    - Deactivate group Running
    }

    It's a lot more optimised than checking the same conditions over and over again.

Similar Threads

  1. Too many conditions/ORs in an event vs separated events
    By DinnerSonic in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 26th July 2012, 04:14 AM
  2. Heavy calculations
    By King_Cool in forum iOS Export Module Version 2.0
    Replies: 3
    Last Post: 25th July 2012, 02:39 AM
  3. Memory Object - Additional Memory Types
    By Cudmuffin in forum Extension Development
    Replies: 0
    Last Post: 22nd November 2011, 12:43 PM
  4. disable/deactivate certain conditions/events?
    By murderdeathkill in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 5th January 2008, 06:49 PM
  5. Why so heavy, these exe?
    By ale152 in forum Multimedia Fusion 2 - Technical Support
    Replies: 24
    Last Post: 7th September 2007, 06:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •