Browse Search Popular Register Upload Rules User list Login:
Search:
Chronic lag?

Image:
screenshot of the scene

Author: AverageCoder

Group: Default

Filesize: 7.79 kB

Date added: 2024-10-22

Rating: 5

Downloads: 1208

Views: 284

Comments: 4

Ratings: 1

Times favored: 0

Made with: Algodoo v2.2.0b

Tags:

Scene tag

Me and ChatGPT made a function named applyForce that takes an object, force, and relative position to calculate and apply a force at a given relative position on the object.
The reason why I named the scene Chronic lag is because I need help optimizing it.
The function works just fine (I think, tell me if its correct or not) but it lags if its called too many times in a postStep.
A way to replicate this lag is to duplicate the red cube a couple times until your computer begins to lag.
I'm confused because the script is relatively simple for a computer and that Algodoo has thrusters that do the same thing but with much better performance.

If anyone knows a solution to this lag, please tell me. And if you want to use the function as it is, you can take it. The function was also intended to be a Scene.my function and thats why it takes a object as an argument.

I intend to make a scene where almost every physical interaction is calculated with thyme. I want to do that so I self-teach myself about physics and to have people learn from the scene.

Also, what does Scene.addContact do?
Last edited at 2024/10/22 01:55:02 by AverageCoder
Please log in to rate this scene
edit
Similar scenes
Title: Algobots vs Realbots Battle 5 Result
Rating: 5
Filesize: 0.96 MB
Downloads: 170
Comments: 1
Ratings: 1
Date added: 2017/01/05 09:47:13
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Algobots vs Realbots Battle 6
Rating: 5
Filesize: 0.96 MB
Downloads: 224
Comments: 0
Ratings: 1
Date added: 2017/01/06 08:57:15
Made with: Algodoo v2.1.0
Rating: rated 5
download
_functions defined within _applyForce are creating a memory leak. Fixing the memory leak should reduce the lag.

The memory leak can be seen by using the Task Manager.

The memory leak can be fixed by adding:
  divide = "";
  abs = "";
  rotate = "";
  xfor = "";
to the end of the _applyForce function.
Last edited at 2024/10/23 00:40:22 by s_noonan
In the Algodoo Forum user kilinich wrote: New entity "contact", to create call scene.addContact (used for adhesion simulation I guess)

I was not able to find any other reference to it.
I beleive a contact is refering to the unused batery and wire tools.
@s_noonan I decided to try making the problem much worse to see how much memory Algodoo 2.2.3 can use before crashing.
My computer has a total of 32GB of memory (It's a mini PC though, so the GPU and CPU share memory and the CPU only has 28GB)!
When I started writing this comment, Algodoo was already using 18GB which is far more than 2.1.0 could handle! :lol:

Surprisingly, at 18GB, Algodoo 2.2.3 runs fairly smoothly! I was even able to save without the "Out Of Memory" error.

I started feeling noticeable slowdowns at 22GB, presumably as my computer starts having to move more memory around. Surprisingly -- after that, Algodoo got super slow for a few seconds before RAM usage plummeted back to 10GB! :lol:

It's unclear to me whether this cycle would repeat however, but unfortunately (or, i guess fortunately if you think about it) it took several minutes for Algodoo to reach such a high memory usage, even with me making the problem an order of magnitude or two worse. I have really, really bad ADHD so I can't stare at Task Manager for possibly hours for a simple experiment :(

As for what I did to make the issue worse, I replaced the force function with a function that recursively defines a copy of itself multiple times and then spawned way more boxes with this new function..... :(
Last edited at 2025/01/04 18:15:47 by Little