← Back to team overview

lightspark-users team mailing list archive

Plan for memory usage and GC support


Hi everyone,

I'd like to discuss a problem I've been working in the last few days.
I'm currently spending some time trying to get FarmVille to work, which
would be a fairly large milestone for the project, being an heavyweight,
interactive game. In my progress I'm currently hitting a memory usage
wall. I think the main problem is that ligthspark does not implement yet
a gargabe collector beside reference counting, which means that object
cycles are not freed until the flash instance is terminated. I've tried
to use Bohem GC (libgc) to solve the issue


Basically Boehm GC is a stop-the-world mark and sweep collector. The
stop-the-world part is really problematic since the collector will stop
all threads using signals every once in a while. This causes some very
serious slowdowns and that made me currently put such library aside. If
anyone has experience with it feedback would be very welcome. The
experiment has been useful anyway since I've used the leak detection
capabilities of the library to fix quite a few reference counting errors
that were causing memory leaks. Another side issue is that the collector
is "global", that's to say that it's not possible to isolate a instance
of flash from another one and the collector has to work on all the
objects from all instances together.

Moreover, I also think that objects themselves are bloated, since I've
actually never spent any time in optimizing their size.

The way I would like to approach the problem is twofold:

1) Employ custom allocators to wrap heap traffic while accounting who is
using memory (similarly to what mozilla developers have been doing for
their MemShrink project https://wiki.mozilla.org/Performance/MemShrink)
This would make it possible to profile what should to be optimized)
2) Use object cycle detection to deal with the limitation of reference
counting, similarly to what python does. I'm still investigating on

Any feedback/suggestion will be much appreciated, sorry for the length
of the mail,

Follow ups