How To Optimise Memory Usage In Your Unreal Engine 5 Game

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ธ.ค. 2024

ความคิดเห็น • 70

  • @Alternatywny_1
    @Alternatywny_1 หลายเดือนก่อน +1

    Thanks to you, I finally figured out how interfaces work and how to create them, as well as how they can help me optimize my project. I was really struggling with this, but now, thanks to you, I’ve got it all sorted. Once again, a huge thank you! :))

    • @MattAspland
      @MattAspland  หลายเดือนก่อน

      That’s amazing to hear! I’m very happy I could help you out! :)

  • @1.1st
    @1.1st 10 หลายเดือนก่อน +27

    An important lesson. I hope you make more of optimization lessons

  • @PatrickTheDM
    @PatrickTheDM 10 หลายเดือนก่อน +16

    So it's a way of creating a soft reference as opposed to a hard reference. Really helpful!

    • @ryanjdev87
      @ryanjdev87 10 หลายเดือนก่อน +5

      best way Ive found to do that is to have the interface return a soft reference then you can load that and have full access to every var and function on the BP without making the interface cluttered with a ton of gets and sets ... it can just have 1 function called ReturnSelfSoftRef :)

    • @PatrickTheDM
      @PatrickTheDM 10 หลายเดือนก่อน

      Makes sense. I'll have to set it up to really understand it. Thanks!@@ryanjdev87

    • @mam9zyc
      @mam9zyc 5 หลายเดือนก่อน

      @@ryanjdev87hi, i know it's been 5months (lol) but can you explain your solution in a simplest/more visual way?🙏🏻 im a beginner and dont get it yet but already making a game, understand that it'll be heavy on memory and i believe with you trick i will not be doing this mistake👊🏻

    • @TheSoprah
      @TheSoprah 3 หลายเดือนก่อน

      @@mam9zyc Feed Chat Gpt or any AI with the text ryan said and the context you are in. AI will help you! I work the same way.

  • @TorQueMoD
    @TorQueMoD 10 หลายเดือนก่อน +8

    This is hands down the best video you've made so far :) Super straight forward and simple explanation of a subject that a lot of people (including myself) completely miss with Blueprint programming. I'm shocked that casting is even an option now after seeing this. Love it!

    • @MattAspland
      @MattAspland  10 หลายเดือนก่อน

      Thanks for the support! It’s always a pleasure to help :)

  • @meh.2689
    @meh.2689 8 หลายเดือนก่อน +3

    Would an in-depth tutorial be possible regarding optimization

  • @wolffuschia
    @wolffuschia 10 หลายเดือนก่อน +13

    Tip there is no point avoiding casts entirely, if something is constantly used or loaded (ie player character) cast away as it will not duplicate and waste memory.

    • @MaxHorror
      @MaxHorror 10 หลายเดือนก่อน

      So just go nuts with casting to your character?

    • @wolffuschia
      @wolffuschia 10 หลายเดือนก่อน +2

      @@MaxHorror Essentially as the only reason to avoid casting is to avoid hard references, which then wastes memory, but if something’s constantly in memory casting is fine but also look into blueprint interfaces and blueprint function libraries, as they do the same thing but are just a lot cleaner code.

    • @MaxHorror
      @MaxHorror 10 หลายเดือนก่อน +1

      Thank you @@wolffuschia

    • @jomesias
      @jomesias 6 หลายเดือนก่อน +1

      Cast once, on begin plat let’s say, and store it to a variable.
      You just reduced your casts to 1! 💯

    • @wolffuschia
      @wolffuschia 6 หลายเดือนก่อน +2

      @@jomesias If it is something that will always be loaded in memory such as gameInstance, Player character. But avoid doing this on things that are not persistent, such as an item from one level that is not in another level :)

  • @CRUMVIII
    @CRUMVIII 10 หลายเดือนก่อน +8

    Very interesting and useful video. Always good to learn more about how to optimize. Thanks for teaching this.

  • @jomesias
    @jomesias 6 หลายเดือนก่อน +2

    You can also use tags as an alternative to casting or comparing to the class we need.
    Actor has tag, or get all actors of class with tag (this is more expensive though because it scans the Level Hierarchy.
    Another alternative is to check if it implements an interface

  • @IcyLucario
    @IcyLucario 10 หลายเดือนก่อน +3

    Can't believe I didn't know about Size Map until now...
    Thanks so much Matt! I have a grid-based game and one of the tiles was 200mb, now down to 68. There's easily 100+ of these in any level. This was also how I learned to CLEAN UP BLUEPRINTS AND MATERIALS because I did not realize unused things left in the graph are actually still being referenced. That makes total sense, given how blueprints are just code, but I did not realize it until now. I had at least 3 large textures being referenced despite them not even being used. Whoops!

  • @biaxthepanda
    @biaxthepanda 10 หลายเดือนก่อน +1

    Great tutorial. More people should be aware of this.

  • @amerboss99
    @amerboss99 10 หลายเดือนก่อน +1

    Please keep up with these rare tutorials man!❤

  • @ujugamestudio
    @ujugamestudio 8 หลายเดือนก่อน

    A proper lifesaving tutorial, he shows proper way of doing things, I subbed ❤❤❤

  • @UnrealExpand
    @UnrealExpand 10 หลายเดือนก่อน +1

    Perfect video and a great first look into interfaces and optimisation.

  • @abdullahsohail5395
    @abdullahsohail5395 10 หลายเดือนก่อน +1

    really interesting topic u covered thanks mate keep doing great job.

  • @Spink4l
    @Spink4l 10 หลายเดือนก่อน +2

    Exactly what i needed, thank you

  • @guibel844
    @guibel844 10 หลายเดือนก่อน +1

    thank you, this is really helpful

  • @haody_makes_things
    @haody_makes_things 2 หลายเดือนก่อน

    From what I understand, each object references the player, but they won't actually load the player each time or load a separate copy. They are still just references. Player is always loaded anyway, so really won't be an issue. It will be an issue if they are somehow doing a cast of some other object that won't always be loaded. This would cause extra memory to be used.

  • @ryanjdev87
    @ryanjdev87 10 หลายเดือนก่อน +1

    another thing if your having memory problems is to look at the memory profiler and you can even build and launch the game using memory insights for further debugging. Another big tip is that I was using 16GB or ram for a long time while making my project everything ran fine untill I added alot of 4K textures in the game. I was using over 95% and UE5 would crash with out of memory errors all the time. If you ram is over 70% usage I would say double it (like I did from 16GB to 32GB etc) and ue5 will just be alot happier all the time not shifting Gigs of memory to compensate for your lack of memory. Also make sure to remember that what the editor is showing in the top right of ue5 if you have it enabled is the memory usage for the editor and the game. You have to build the game to see what it will use without the editor on top

  • @juanmilanese
    @juanmilanese 6 หลายเดือนก่อน

    finally a good explanation on why casting can be "bad"

  • @PiterTraceurFA
    @PiterTraceurFA 10 หลายเดือนก่อน +1

    Super helpful

  • @retr0_455
    @retr0_455 10 หลายเดือนก่อน

    I optimise my game by 0.5 GB down thank you!❤

  • @real2late
    @real2late 10 หลายเดือนก่อน +2

    I know that naughty dog hat limitations for their entire combat system to be under 5mb. 100mb for one item bluepeint is crazyyy

    • @real2late
      @real2late 10 หลายเดือนก่อน +1

      @@DadBod1818 TLOU1 was in a talk about their combat system on gdc i think

  • @aurustarsia5244
    @aurustarsia5244 10 หลายเดือนก่อน +2

    Wow this really is a great way to save up memory. Thank you!
    I have a question:
    When I started my project I was new to unreal engine. Meanwhile I really do understand it pretty good. But back then, I used a "cast to 3rd person char" for every variable I wanted to reference. So when I wanted to reference to six variables, I used six "cast to" nodes.
    Nowadays I would only use one, or just use your method now.
    Do you have some tips on how to port the old "cast to" nodes to the new method? I mean, if I delete them, all my variables will get invalid. So I must place all the BPI interfaces and manually replace all the variables. Or is there any way to like "automatically replace" these "cast to" and their variables with the BPI method?
    Thanks and best

  • @burgi6236
    @burgi6236 10 หลายเดือนก่อน +3

    Hello Matt, does it not in certain situations make sense to have stuff already in memory? stuff that you are going to interact with i mean? and why is the player character using extra memory, it should be in memory at all time anyway? i dont really understand... i mean, we live in times where microstutter, stutterstruggle and so on is persistant everywhere.. so, did you ever compare a worst case szenario when running a game with more memory usage and with less? I mean, having more stuff in RAM or VRAM is not a bad thing, isnt it?

  • @TheSalmon451
    @TheSalmon451 10 หลายเดือนก่อน

    Oh my goodness., Thank you. I reduced memory use of my game by gigabytes in five minutes using this advice.

  • @franknorris987
    @franknorris987 10 หลายเดือนก่อน

    thanks, easily useful

  • @cbomcnasty
    @cbomcnasty 10 หลายเดือนก่อน

    Great video

  • @AvB.83
    @AvB.83 10 หลายเดือนก่อน

    Edit: I'm not sure I understand anything anymore 😅 I have a character generation menu, where you can basically pick from an array of metahumans, but the data table that holds this list will always load ALL the materials etc.?
    Thanks! I finally understand WHY you should avoid casting. Everyone always says "you should avoid casting, it's harder on the performance, do this instead", I don't think I ever read or heard someone explain why that is and how much more ressources it takes.

    • @lennysmileyface
      @lennysmileyface 10 หลายเดือนก่อน

      You should use soft references in data tables.

  • @Lilium___
    @Lilium___ 6 หลายเดือนก่อน

    What I've always been wondering is how bad the reference really is. Yes in this this case that would load the third person character into memory, but that's only a one time thing right ?
    So even if I have 10 of those pick-ups, only one third-person blueprint would be in memory with each having a reference to it ? And since it's the player character, the third-person bp would be in memory anyways no ? That would mean having a reference to it in all other BPs wouldn't use more memory ?

  • @Xodroc
    @Xodroc 10 หลายเดือนก่อน

    I recently stumbled on to something. A GPU with a lower amount of VRAM will have less editor VRAM usage than a GPU with a larger amount of VRAM.
    I was shocked and surprised when my 24GB RTX 3090 was getting out of video memory errors compared to another user with an AMD card with 16GB VRAM that had no trouble. Using an identical project, the 3090 had around 4-5 more GB usage, ruled out background apps as well. Then I repeated the test on a laptop mobile 3080 GPU with 16GB of VRAM and it also had lower VRAM usage than the 3090 in the same project.
    It's been suggested that the Unreal editor may be allocating extra VRAM based on the maximum amount of VRAM available. It's also possible that windows or even Nvidia drivers are a culprit. Either way, what's the point of having more VRAM if that extra VRAM is not going to be available?
    It's very easy to test and confirm this if you have multiple computers with different sized GPUs.

  • @omerfaruktank5086
    @omerfaruktank5086 10 หลายเดือนก่อน

    For example I want to communicate with two blueprint and none of them playerCharacter. What should I connect target part of interface node

  • @Drachir08
    @Drachir08 8 หลายเดือนก่อน

    What about using Common Function Library to cast to the character and then calling that function. Does it work thr same as using the Interface?

  • @AfterHoursDevchannel
    @AfterHoursDevchannel 4 หลายเดือนก่อน

    Maybe silly questions but does the scene== MEMORY see al these BP_Items as its instances=== taking only 111,3 Mb in memory or does it count X times when you have X such actors in the scene. I'm 99% sure it sees them as instances so takes only 111Mb in memory for this "kind" of object, just wanna be sure

  • @KittehBit
    @KittehBit 8 หลายเดือนก่อน

    Very cool video. I am wondering if the references increase the overall memory needed, if multiple object reference an asset. For instance, if 4 cubes reference the player character, is it 4x 100mb or is it only 100mb, because its the same reference. Also, since the player character is probably also in the scene, would removing the hard reference actually reduce the memory size, since its already in memory? I know its not the point of this video, but still curious about how (or if) UE handles deduplication.

    • @Tegurd
      @Tegurd 7 หลายเดือนก่อน

      It's 0 because the player character is probably always loaded anyways. You should be very wary of casting from the PC to other objects though because then they are kept in memory

  • @CrypticaProductions
    @CrypticaProductions 10 หลายเดือนก่อน

    Amazing

  • @DrovalNaper
    @DrovalNaper 3 หลายเดือนก่อน

    Great optimisation from 109 mb to 1.7 mb.

  • @m23rco
    @m23rco 6 หลายเดือนก่อน

    Can this solve the crash about kernel32/malloc block...??

  • @MartKart8
    @MartKart8 10 หลายเดือนก่อน

    When I make things, Like Materials, I tend to make them 1K and not the 4K materials, I guess this helps, when taken from Blender to a game engine.

  • @hipoojan
    @hipoojan 10 หลายเดือนก่อน

    Wow, this should be default way to do references don't know why other tutorials don't mention this. Can you make one for Lighting and Graphics, I swear even the basic ThirdPersonGame when exported uses 100% GPU for some reason

  • @drakouzdrowiciel9237
    @drakouzdrowiciel9237 8 หลายเดือนก่อน

    Thx

  • @vitaliiy-ub4um
    @vitaliiy-ub4um 3 หลายเดือนก่อน

    super

  • @maxten1463
    @maxten1463 10 หลายเดือนก่อน +1

    When should you cast? Why does it exist

    • @philzan3627
      @philzan3627 10 หลายเดือนก่อน +3

      casting is the equivalent of calling the class itself and pointing to the object of that class. It is a pretty big misconception that casting is costly by today's standards.
      The problem is that if you hard reference everything and you cast to a previously unloaded class, it will load all references in it as well, making it "costly". But your player character, that is pretty much always loaded, doesn't cost a thing at all.
      Casting is basically like saying, "I want to get this object of this class, give me all associated information".
      Interface is basically "send a message of this interface to this object"; if it has the interface and a corresponding event, it does stuff; otherwise nothing happens. Very good for systems like damage, or messages.
      Delegates are like subscriptions. When actor A does and event, instead of it having to fetch all other actors and TELL them to do it, all actors spawn and are subscribed to that event. When it happens, they know!

    • @maxten1463
      @maxten1463 10 หลายเดือนก่อน

      @@philzan3627 Thanks a lot! you put that together really well

    • @Tegurd
      @Tegurd 7 หลายเดือนก่อน +1

      You can cast to the player character as much as you want. It's always loaded anyways. Same with player controller, gamestate, level blueprint and game instance. Cast away there. Be wary of casting away from these though

  • @zeymjaj
    @zeymjaj 10 หลายเดือนก่อน

    would you still go with interfaces over casting when it comes to communicate with GameState/PlayerState/Controllers etc... ?

    • @philzan3627
      @philzan3627 10 หลายเดือนก่อน

      You could do either but it doesn't matter. Since the game state or controllers are always loaded, casting doesn't add any more or less ram. You just make a call. To be honest, it is way easier to cast than to set up interfaces and events for every single variable.

  • @julianbridges838
    @julianbridges838 6 หลายเดือนก่อน

    *Breathes in* lets sort this snakes wedding

  • @evilpotatoman9436
    @evilpotatoman9436 10 หลายเดือนก่อน +1

    I right clicked one of my blueprints and it said 4GBs.... I store all my casts in variables so hopefully its fine :/

    • @VillanoWild-or4bs
      @VillanoWild-or4bs 8 หลายเดือนก่อน

      If it works on the platform you have planned, don't worry too much, mine weighs 7GB and works well on low-resource pcs

  • @AndresAlfaroAtonal
    @AndresAlfaroAtonal 10 หลายเดือนก่อน

    it works for ue4?