Skip to main content
Inspiring
April 11, 2018
Question

[VERY UNCLEAR] Abnormal memory allocation by calling function

  • April 11, 2018
  • 1 reply
  • 357 views

Hi Guys,

Did anyone ever encounter such abnormal behavior with Garbage Collector. This is happening for me since AIR 24. So as long as I can remember. Now I am using latest AIR 29 and it is the same story.

This makes it impossible to create game in AIR. I really do not know what to do because Scout is not giving me any info.

Take a look at screen shot just before GC kick in:

https://ibb.co/ifYpHH

And when GC kick in:

https://ibb.co/j78BWc

So according to Scout GC clears around 40MB of memory but it does not tell what has been cleared because as you can see in the Memory Allocations tab there are just couple of objects.

So when I play my game without allocating any objects what so ever AIR is allocating 40MB each 30 seconds and than GC clears it and than my game stutters and gaming experience is degraded heavily.

So how on earth should I know what GC is doing if Adobe Scout is not showing me and why is AIR allocating 40MB of memory every 30 seconds?

When I select time between 2 GC runs Scout is also not showing what is allocated to justify 40MB increase. Take a look at the screenshot:

https://ibb.co/kt4ocH

This topic has been closed for replies.

1 reply

chakyAuthor
Inspiring
April 13, 2018

I have FINALLY found the cause of this. BUT it is VERY VERY VERY UNCLEAR why it is happening. At least to me. Maybe some limits are broken in Flash

As you probably know Box2d has Velocity and Position iteration count when calling b2World.step() method.

So for whatever value you have set for Velocity and Position iteration Bo2d will call SolveVelocityConstraints and SolvePositionConstraints that amount of time for every joint on every frame.

So for example if you have set 800 (overkill just for test, should be a lot less) for Velocity and Position iteration count Bo2d will call SolveVelocityConstraints and SolvePositionConstraints 800 times on each frame.

But I have refactored those methods for all joints (Revolute, Prismatic, Weld etc) and in those methods nothing is allocated. So why would flash allocate so much memory just if you call those methods many times in a single frame.

Can you PLEASE take a look at those methods and see if something is weird that could allocate so much memory. Here are the files for b2RevoluteJoint, b2WeldJoint and b2PrismaticJoint:

Revolute:

https://pastebin.com/ZkY9XFpu

Weld:

https://pastebin.com/wtYa6xFZ

Prismatic:

https://pastebin.com/gx50XFAf

So only methods you need to look at are SolveVelocityConstraints and SolvePositionConstraints. When calling those methods multiple times in a frame 1MB, or 2MB or ever 3MB are allocated every second depending how much times are those methods called. If I set Velocity and Position iteration count to be just 40 it will allocate 1MB every second.

Can you see something that could cause abnormal memory allocation?

I really do not understand what is causing memory allocation in those methods. I am not using new operator anywhere. Adobe Scout is also not showing anything.

This is the version of Box2d I am using:

https://bitbucket.org/hardcoremore/box2d/overview

use only refactor/object-pooling branch.

chakyAuthor
Inspiring
April 13, 2018

Here is the proof that Adobe Scout is not showing what is allocated. Look at the profile. How can that be?

http://bit.do/edAG7