Re: Memory tracking in GJS


On Thu, Feb 20, 2014 at 9:50 AM, Cosimo Cecchi <cosimoc gnome org> wrote:

Any other ideas? I feel this is a fundamental enough issue that there must
be a good way to design a generic solution.

Something else that's quite controversial would be to add a new,
optional virtual function to GObjectClass to query the amount of
memory used by the object at any given time. Only the object itself,
which has knowledge of its private details, is able to determine this
information reliably.

There's only two situations when it might not be able to do this:
 - 1. When it has pointers to other GObject objects with private data,
in which case it can just call through the same virtual function and
accumulate memory.
 - 2. When it has pointers to other non-GObject objects with private
data, in which case it will need to provide an estimate.

Its controversial because we'd effectively be pushing the reporting
responsibility to the objects itself, but every solution which I've
come across for this so far is either unreliable or not something we'd
want in a production release.

This isn't exactly a completely solvable problem because there's no
one place that we can override and track all allocation, which is kind
of what mozjs' garbage collector wants. Best thing we can do is
provide an estimate.



gtk-devel-list mailing list
gtk-devel-list gnome org

Sam Spilsbury

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]