On Thu, 27 Nov 2008, Rodrigo Miguel wrote: Hi Rodrigo,
> I'm facing in some rare cases the "Warning, memory allocated but not > released: 1124 bytes (16 block(s))" due to the unfreed allocate HB > ITEM. For some unknown reason, when gtk is terminated abnormally, it > doesn't call the gc closure notify. Here are some examples that I'm > using for: [...] What does it mean terminated abnormally? When application crashes? If you have FM log message then it's not whole application crash or Harbour internal error. I guess it's RT error. Am I right? Or maybe you are talking about sth different. > So the one million question is. Is there any way on Callback() > function to use the Harbour GC to free up the allocated when it's > completed, then I would not need rely on GTK Closure notify? Any > suggestions? The answer is simple. It cannot. It simply does not know anything about GTK internal structures and how to look for references to harbour memory blocks in them so it cannot decide if GTK keeps some pointer to our memory blocks or not. To make such things it's necessary to use garbage collectors which are not oriented for some given data types but scan whole application memory and C call stack (or stacks in MT programs) and check all references in whole allocated memory. For such collectors it's necessary to keep strict memory alignment in whole application and all libraries used by this application. It's forbidden to use any #pragma pack commands in all source code used to compiled the application or store pointers in memory which is not well aligned or keep only modified pointers without direct referencing. It's also necessary to set NULL for all freed memory pointers which are not longer used and can be accessed be references from static variables. Such collectors exists for some platforms but as you can see they can be used only in very limited situations when whole code also system and 3-rd party libraries is designed to safely work with them. It means that they cannot be used by us. They are usually not as good as people think in real multiprocess environment and applications which use them consumes much more memory often activating swap when you run more then one such application simultaneously killing overall performance. And the worst thing is that it's not possible to detect any memory leaks caused by pointers which are not NULLed when they are not longer necessary. Just simply people are happy that memory leaks are not reported. Returning to your problem with GTK. When exactly the problem appears? After RT error? Is it GTK bug or it's necessary to close Harbour application without closing GTK. If you say sth more maybe I can help. best regards, Przemek _______________________________________________ Harbour mailing list [email protected] http://lists.harbour-project.org/mailman/listinfo/harbour
