User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Slow Memory Leak using Active Object with Active Direct Show.

  1. #1
    Clicker Fusion 2.5 (Steam)

    Join Date
    Nov 2019
    Posts
    40
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question Slow Memory Leak using Active Object with Active Direct Show.

    Hello, I've encountered a strange issue with my current game. I'm getting a slow memory leak as I progress through the frame and I don't know why.

    In my frame, the player is able to "move" throughout the environment in a psuedo-free roam way by playing pre-rendered movement animations in video format. There is an active object in the frame that has 34 animations, each containing anywhere from 3 to 8 frames. The player is able to move and turn via the video animation via the active direct show object, and then the active direct show is moved beneath the active object, which displays one of these frames in one of these animations.

    active object.jpg

    The problem I have is that as the player goes through these actions of video playing -> move beneath other active object image, the memory usage creeps up by about 9-11 Mb each time.

    Here is a video demonstrating what I'm talking about.



    As you can see, the memory starts at about 500 Mb, but as I continue, it creeps up to 650 MB when everything in the frame is resting. When I tested the movement gameplay a while ago as I first found this out, it just kept creeping up, eventually even up to 1400 Mb!

    I've searched through my code for what could be causing this, and I couldn't find any obvious (to me) problem with it. I don't believe I'm creating duplicates of things, and I've already tried changing my Active Direct Show object to be a version specifically fixed from its own memory leak issue.

    I'm confident it has something to do with the active object that contains all the animations. Perhaps there is some process going on behind the scenes that keeps eating up more RAM as each of the images in that object are displayed. Maybe it has something to do with resampling, as I've looked at in this old post?: https://community.clickteam.com/threads/56733-Background-Images-Memory-leak

    Having the object set to "Load on Call" doesn't help, neither does unchecking that option. When I don't create the active object at start, the memory is at about 87 Mb, so I know that the bulk of the normal 500 Mb memory is dedicated to most of the active object's images already being loaded in.

    In total, the amount of information the active object should need is about 500 Mb on it's own, which is fine and expected, but I don't believe that number should be growing as I use it.

    Here are my settings for my application if that's needed:

    options 1.png


    options 2.png


    And here are the settings of the active object in question:

    options 3.png


    Please let me know if you guys need more information.

  2. #2
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    276
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Have you tried creating a new MFA with just the 500mb active object and seeing if it replicates the same issue? That might help isolate further if it's the code or the object itself

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,951
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    I could definitely be wrong, but this is my guess:

    1. Your videos are in a compressed format. Either MPEG video, or series of still images using a compressed format like PNG. When looking at the total combined filesize of these compressed files, they appear to be 500MB.

    2. Just as Windows must decompress a ZIP to open the files inside, Fusion must decompress your images to display them. So Fusion decompresses them as it goes. Effectively, it turns each frame into something like a BMP (which, although it appears visually identical to a PNG, is much larger).

    3. As you progress through more of the game, Fusion decompresses more and more of images/videos, storing them in memory as it goes. Eventually, it will have stored close to the full amount of decompressed data from your videos, which will be larger than the total compressed size of the files themselves.


    If my guess is correct, then perhaps it might help to break up your videos into smaller chunks, rather than using a single active with all 34 animations in it. Then, at strategic times, you could destroy and re-create some of those chunks in the background, to force Fusion to purge the decompressed data it's accrued from them and reload the tidy compressed versions.

    Also, if you don't have the 2.5+ DLC, I believe it contains some sharper memory management, so getting it might help your situation, though I actually have no idea if it would help in this particular situation at all. Though probably worth trying, because the many other features in 2.5+ are fantastic and will make your life easier in various ways, so it's a highly recommended upgrade anyway.

  4. #4
    Clicker Fusion 2.5 (Steam)

    Join Date
    Nov 2019
    Posts
    40
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    So I did more testing. I thought for sure that I had Fusion 2.5+, but turns out I didn't, so I bought that. The problem didn't go away, and so I used a test frame and only used the active object with the 34 "animations", (really they're just sets of still images for the player to see when none of the actual video animations are playing.)

    What I found is interesting. I coded it so when I pressed the space bar, the object would go to the next "animation" (set of still images).

    Here's a video of what happened:



    As I progressed through the active object animations, the RAM usage built up, but eventually once I got to the end, the RAM decreased all the way back to about 500 Mb again!

    When I used the arrow keys to scroll through the still images in one of the animations, the RAM went up, but didn't go down. In all honesty, I'm fine with that if the RAM eventually "resets" for each "animation" (set of still images). The player also wouldn't be able to actually move this fast in the environment in actual gameplay.

    So really, the active object doesn't necessarily seem to be the real culprit for why the RAM usage doesn't go down. So my only guess is that there is something going on with the Active Direct Show Object.


    This is an example of the first part of how the video transition is played.
    How video is working 1.png

    There is a dance of code between ordering and such of the still images from the active object and the active direct show object in order to avoid the black screen at the start of every video that comes from loading it in, but I don't think that's necessarily affecting the RAM build up.

    The video transition files are also accessed with a few strings that change depending on the situation, but ultimately I checked "Include External Files" in the application settings, because the total amount of video files I need to access is probably too much for binary data alone, so I understand I'll need to create an install program.

    Finally, the "Play Swivel 2" is a set of instructions shown below:

    How video is working 2.png

    My best guess is that something is going on with the active direct show object where some of the video information gets stored or is left over after each video plays. In the first video I posted, there is a jump of about 100 Mb when playing the video, but that eventually goes down, but not all of it does. There seems to be left over RAM usage that unlike the test frame, stays in place, and I'm wondering if I'm not properly using the active direct show object when it comes to playing many types of video files.

    Should I destroy the active direct show object after it is used? Or should I "close" the video after it's done or something?




    [End note about compression on my files]

    The still images I'm using are in PNG format, and as far as I know they should only have about 15% "compression" on them from being rendered in Blender.

    The video files I'm using are compressed in the "Perceptually Lossless" option in the Blender 3.1 Video Sequence Editor, and are saved to an AVI format.

  5. #5
    Clicker Fusion 2.5 (Steam)

    Join Date
    Nov 2019
    Posts
    40
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    @Volnaiskra

    Additional Note:

    When "Optimize Image Size in RAM" is unchecked, the RAM usage jumps up to about 1450 Mb. When I progress through the frame, it still keeps going up.

  6. #6
    Clicker Fusion 2.5 (Steam)

    Join Date
    Nov 2019
    Posts
    40
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Some more info:

    I built the current version, and verified that it does continually leak memory according to the task manager.

    I've been messing around with destroying the active object and re-creating it in order to release the memory, but that doesn't seem to be working. Also I've tried using the "close video" option in the active direct show, but no results there either.

    Such an odd issue.

  7. #7
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,951
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    Try destroying and recreating the direct show object if you can.

  8. #8
    Clicker Fusion 2.5 (Steam)

    Join Date
    Nov 2019
    Posts
    40
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Doesn't seem to work all that much, the bulk of the left over memory remains. I don't know if there's some kind of option in the settings that keeps the memory of objects even if they're destroyed.

    It is really odd, it makes me think that the direct show object is storing some kind of information from its access of each video file, and that's what is going on. I'll probably try a few different things and change my approach.

    I've tried a lot of things, at this point I might as well upload the .mfa for people on here. I won't be able to do that though until tomorrow.

  9. #9
    Clicker Fusion 2.5 (Steam)

    Join Date
    Nov 2019
    Posts
    40
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Okay I did more testing, and I had some interesting discoveries, and possibly an epiphany.

    I made a second test frame where I only had the active direct show object, and I then wrote some code to play a small amount of the video files , each one based on what the value of a counter was at the time. (I also included a limit condition so it wouldn't perpetually load and play over and over again). It turns out, the memory leak that is present in the original frame doesn't occur. After playing about 40 of the video files, one after another, the RAM only fluctuates by about 2 Mb from the initial amount.

    So it's not solely the active direct show object, nor is it solely the active object. The active object alone increases RAM usage, but also releases it. Direct Show alone doesn't perpetually increase it. Yet these two together in my original frame with my original code keeps building up the RAM the more I use it.

    And here's where I realized something about my code.

    originally.png

    This image shows what I originally coded: the player would press "W" and a video would play.

    But then I changed it to this:

    currently.png

    Using the Key Object, I managed to let the player seamlessly "move forward" by keeping "W" pressed down at the end of the video file, so that it would immediately play the next one.

    The problem I see is that there is no limiting condition there, so perhaps this set of instructions are being perpetually done for a while, even if I'm only pressing the key for a short second.

    I don't know if this is actually happening, and I don't know why this would result in the memory leak, since nothing is being created or added in the resulting process, but who knows, I'm out of ideas of what could be causing this.

    I'll see if it fixes it tomorrow.

  10. #10
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,951
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)


    This might be ok because of conditions #2, #3, and #4. Without those conditions, it would be firing ad nauseum 60 times a second or so, which would certainly be a bad thing. The Key Object's is key down condition is effectively the same as Fusion's native repeat while key pressed condition. (though only the Key object can detect keys even when your application is minimised, but that's probably not relevant to this project). But because of conditions 2-4, it should only fire once per video (ie. it sets Animation to 1 and Counter to 1, which will prevent the event from refiring immediately).

    I haven't used the Direct Show object much, so don't really know how it works, but this makes me wonder:



    You're loading a video from disk every time the user moves. Presumably, the same video(s) will be loaded multiple times if the user retreads the same locations. Perhaps there's some sort of overhead that get loaded each time, resulting in the memory leak. You could test this by loading the same video over and over again with a keypress, and seeing if the RAM fluctuates.

    What would happen if you had separate Direct Show objects, each with a single video loaded in to it (once, and never reloaded again), and switch between those objects rather than overwriting the video in the same object each time - does the RAM still fluctuate? (Try testing with 5 or so - no need to set up all 34). Just throwing up ideas.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Active Direct Show Object
    By _peixe_ in forum Fusion 2.5
    Replies: 2
    Last Post: 15th July 2021, 01:15 PM
  2. Active Direct Show Memory Leak
    By IvanG in forum Fusion 2.5
    Replies: 7
    Last Post: 11th July 2021, 08:22 AM
  3. Replies: 5
    Last Post: 9th October 2020, 06:25 AM
  4. Replies: 1
    Last Post: 24th September 2015, 02:27 PM
  5. Active Direct Show Object Problem
    By nando1962 in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 23rd July 2012, 03:50 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
  •