[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Request
[Thread Prev] | [Thread Next]
- Subject: Re: Request
- From: Fabien Bodard <gambas.fr@xxxxxxxxx>
- Date: Fri, 3 Oct 2025 15:57:12 +0200
- To: user@xxxxxxxxxxxxxxxxxxxxxx
Le ven. 3 oct. 2025 à 15:40, Benoît Minisini < benoit.minisini@xxxxxxxxxxxxxxxx> a écrit : > Le 03/10/2025 à 14:37, Fabien Bodard a écrit : > > Hi Benoît, > > > > One of the most annoying things when coding with Gambas or any other > > language is this: > > > > gbx3: warning: circular references detected: > > gbx3: warning: 1 Settings > > > > gbx3: warning: 30 allocation(s) non freed. > > > > We spend hours trying to find where references are duplicated or looped. > > Is there really no way to optimize this? > > > > Without this difficulty, Gambas would be even better than it was... > > > > A way to control the shared scope, like Rust? > > > > Or traceability of references at a given point in time? > > > > I don't know, but it would be a great help. Because even if I limit > > direct references, there's always a point where things go wrong. > > > > -- > > Fabien Bodard > > If you pay attention to avoid any possible linked reference between > classes, i.e. by never having a variable of class A that contains a > reference on class B, and the opposite, then it will never happen. > > But I admit that if you are not careful, and if you create complex > circuits (A -> B -> C -> D -> A), with arrays and collections containing > references, then it's almost impossible to find how the circularity was > created. > > Moreover, the "circular references" message does not mean that there are > circular references! > > It actually means that some objects were not freed at the end of the > program, after all object references stored in static variables of all > classes have been released. > > So it is either actual circular references, or a reference leak bug in > the interpreter. > > In your exemple, only one Settings object is blocked, so that's strange. > Unless you store in the Settings object a reference to itself! > > Then, is it possible to do better? > > I'm not sure, because at the end of the program, when it detects > non-freed objects, the interpreter has no idea where are these pending > objects. It just knows how many of them are. > > But maybe a tool could be created inside the debugger to detect circular > references on demand. It would start from all static variables, and then > will follow references recursively until it finds a loop. > > It must be on demand, because once a circular reference is created, it > may be unreachable at one time. For example, you create A -> B -> C -> > B. Then you release the reference on B in A, and then you have B -> C -> > B that becomes unreachable because it is not referenced by anything. > > I will think about that... > Thank you :-). I'm sure I will found my error but ... so loooong . > > Regards, > > -- > Benoît Minisini. > > > -- Fabien Bodard
Request | Fabien Bodard <gambas.fr@xxxxxxxxx> |
Re: Request | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |