I made the infinite loop error several times with C# using Visual Studio and Unity (Unity Forum commenters couldn't spot my error immediately)- fortunately GDScript makes that difficult to accidentally (and have programming blindness) do but it is possible to access outside an array if you don't include the correct array handling. I could so easy forget to do that. So is there an plug in to GODOT to prevent GODOT using 100% of memory and crashing- preferably pointing out the bad programming?
Is there plug in that converts a memory leak into a simple error message
There some methods in the OS class that might be useful in detecting a memory link:
get_dynamic_memory_usage( ) get_static_memory_peak_usage( ) get_static_memory_usage( )
https://docs.godotengine.org/en/stable/classes/class_os.html#methods
I doubt there's any way of programmatically identifying "bad programming".
You can also profile your game if you think there is a problem.
@DaveTheCoder said: I doubt there's any way of programmatically identifying "bad programming".
I'd pay good money for a plugin that'd identify my bad programming :)
But seriously though, this has apparently been discussed before: https://github.com/godotengine/godot/issues/1587
- Edited
@DaveTheCoder said: I doubt there's any way of programmatically identifying "bad programming".
Actually, if you've ever used JetBrains IDEs, they do a pretty good job of giving you hints and warnings that the compiler doesn't catch. Stuff like using variables with uninitialized memory, redundant statements, ways to optimize your code, etc. It's really nice.
- Edited
One IDE I've used could optionally insert blocks of memory with data patterns before and after arrays and other variables, and detect writes to those blocks. That's mainly useful in a language such as C or C++ that lets you use pointers.
With GDScript, I think that using static typing is very helpful in catching mistakes. But most code that I see, even in published tutorials, doesn't use static typing.
I don't usually bother with static typing much, mostly because I know what variables are which. However, it seems the code-completion works better with static typing. And I think it will be required in Godot 4.0.
- Edited
@DaveTheCoder said: There some methods in the OS class that might be useful in detecting a memory link:
get_dynamic_memory_usage( ) get_static_memory_peak_usage( ) get_static_memory_usage( )
https://docs.godotengine.org/en/stable/classes/class_os.html#methods
I doubt there's any way of programmatically identifying "bad programming".
The bad programming is whatever is causing the memory leak, Whatever is being processed that causes the memory to use > @xyz said:
@DaveTheCoder said: I doubt there's any way of programmatically identifying "bad programming".
I'd pay good money for a plugin that'd identify my bad programming :)
But seriously though, this has apparently been discussed before: https://github.com/godotengine/godot/issues/1587
That seems awfully specific-solving While loops . You access outside an array or possibly dozens of other ways . > @DaveTheCoder said:
There some methods in the OS class that might be useful in detecting a memory link:
get_dynamic_memory_usage( ) get_static_memory_peak_usage( ) get_static_memory_usage( )
https://docs.godotengine.org/en/stable/classes/class_os.html#methods
I doubt there's any way of programmatically identifying "bad programming".
There is poor programming and inefficient programming- just because it uses a little extra memory for small games is not a disaster. Poor programming that uses 8Gb of 8Gb is a disaster. Also two of those values are only available in debug and what is the best way to end the game say I set. If dynamic memory>100 MB {is it returning bytes Stop()
- Edited
@cloa513 To answer your question directly; Looks like there is no plugin that can detect memory leaks and print them as error messages. However Godot is easily expandable and you seem to be quite knowledgeable on the matter, why not try to make such a plugin yourself?
I'd have to very knowledgeable on GODOT- I don't have the knowledge. Are plugins compatible of being fully integrated into the engine because that is what you really want?
Yes, you can make tool scripts that have basically full access to the engine editor. However, you could even just write a normal script, those memory functions in GDScript should be enough to make a simple version.
Permanently running low priority thread that checks memory status couple of times per second and warns if some predefined limits are crossed could be implemented in a couple of GDScript lines. Not that I'd need or want something like this, but if someone insists on having it - it's a 10 minute DIY project.
@xyz said: Permanently running low priority thread that checks memory status couple of times per second and warns if some predefined limits are crossed could be implemented in a couple of GDScript lines. Not that I'd need or want something like this, but if someone insists on having it - it's a 10 minute DIY project.
You'll wish you had it if you ever use some of the poor structured parts of GODOT code- I have heard it mentioned- even though you'd never do poor programming. Please the few lines of Code- for comparison search on Godot Q&A 2D Array and while I can't assess the answers someone certainly thinks most answers were terrible so I couldn't easily the same bad programming.
- Edited
I'm not exactly sure what type of "bad programming" we're trying to fight here :)
Most of infinite loops are a non-problem as their manifestation is obvious - the frame freezes. Infinite loops that eat up memory are not a big deal either, for precisely the same reason. On top of that, the system can never know if an infinite loop is intended or not. Deliberate infinite loops can commonly be seen running inside concurrent code, for example in threads or coroutines.
Actual memory leaks, where memory goes away drop by drop are always hard to detect. That's what profilers/debuggers are typically used for. Fortunately, it's virtually impossible for them to happen in garbage collected languages. And both of Godot's scripting languages have garbage collection.
That being said, I'd still love to see some code examples of these nasty leaks that bother you. Feel free to post them.
Maximum use of memory can cause Unity to crash and you lose stuff and it might get corrupted- I assumed it would be the same for GODOT- and the programmer may not have a clue what is going on because in case using Windows (it could be Windows).
Godot is very stable and you can set it to auto-save your scripts. The chances of corruption are low, and in fact it has never crashed on me once on my main machine (unless I was running stress tests or things outside of normal use). But, of course there is always a possibility, and I'm sure you could do it on purpose if you really wanted to. And yes, you could check for this. Just set a limit like 2GB and if the RAM usage goes above that you can exit the game.