Why/how does the compiler have a non-trivial numberof memory leaks after over two decades of development?
(too old to reply)
J. Gareth Moreton
2018-08-02 18:32:08 UTC
Raw Message
Well, I'm only a volunteer developer, but I'm all for making the compiler
more efficient and stable.  I tend to take the approach of iterative
improvement anyway... start with something quick and dirty (if you can't
easily plan it out perfectly from the start), and slowly improve it over

Gareth aka. Kit

On Thu 02/08/18 19:39 , Ben Grasset ***@gmail.com sent:
I'm somewhat surprised to see all the mentions of try-finally in
response to this.

The issues I found and described here are all clearly just simple cases
of variables being created and then never freed. Part of what likely
leads to this is that the compiler relies in many places on checking
whether or not things are currently nil, and heavily reuses global
variables for this purpose.

So it's quite likely in my opinion that there's places where things are
in fact being set to nil without actually being freed first, which has
the potential to go beyond basic leaks and actually lead to memory
corruption problems than could cause real compiler bugs (and might
already be doing so.)

I really don't think that try/finally is particularly relevant for this
kind of thing, nor would it be good for compiler performance. I do think
however that it's quite viable to get some kind of system in place in
the compiler codebase (hidden behind one of the debug-related ifdefs so
that it never affects normal compiler builds at all) that would allow
for much easier soundness-checking while working on the compiler than
HeapTrace can provide on its own.

I've been trying out a few different approaches in the last few days,
and if there's any interest in something like this from the compiler
team I might post here for feedback once I get something more concrete
worked out.

fpc-devel maillist - fpc-***@lists.freepascal.org [1]

[1] mailto:fpc-***@lists.freepascal.org
[2] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel