www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GC operates in LIFO sequence?

reply MGW <mgw yandex.ru> writes:
Memory allocation and deallocation when an application is being 
completed in GC operates in FIFO sequence.
Is there a possibility to shift GC memory deallocation to LIFO 
mode?

It`s connected with the fact that GUI library (Qt) creates 
QApplication first,
but GC destroys this object first when an application is being 
completed. This leads to the application failure.
If the sequence of memory deallocation on LIFO is shifted, it 
will essentially simplify the cooperation with C++ libraries.
Aug 09
next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
On Wednesday, 9 August 2017 at 13:46:29 UTC, MGW wrote:
 Memory allocation and deallocation when an application is being 
 completed in GC operates in FIFO sequence.
Not really, it operates in an undefined sequence... just whenever it gets around to it in scans. If destruction order is important, you should use RAII or explicit destruction...
Aug 09
prev sibling parent reply Guillaume Piolat <contact spam.com> writes:
On Wednesday, 9 August 2017 at 13:46:29 UTC, MGW wrote:
 Memory allocation and deallocation when an application is being 
 completed in GC operates in FIFO sequence.
 Is there a possibility to shift GC memory deallocation to LIFO 
 mode?

 It`s connected with the fact that GUI library (Qt) creates 
 QApplication first,
 but GC destroys this object first when an application is being 
 completed. This leads to the application failure.
 If the sequence of memory deallocation on LIFO is shifted, it 
 will essentially simplify the cooperation with C++ libraries.
https://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors
Aug 09
parent reply Swoorup Joshi <swoorupjoshi gmail.com> writes:
On Wednesday, 9 August 2017 at 15:47:17 UTC, Guillaume Piolat 
wrote:
 On Wednesday, 9 August 2017 at 13:46:29 UTC, MGW wrote:
 Memory allocation and deallocation when an application is 
 being completed in GC operates in FIFO sequence.
 Is there a possibility to shift GC memory deallocation to LIFO 
 mode?

 It`s connected with the fact that GUI library (Qt) creates 
 QApplication first,
 but GC destroys this object first when an application is being 
 completed. This leads to the application failure.
 If the sequence of memory deallocation on LIFO is shifted, it 
 will essentially simplify the cooperation with C++ libraries.
https://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors
Is garbage collection even useful besides managing memory?
Aug 09
next sibling parent Meta <jared771 gmail.com> writes:
On Wednesday, 9 August 2017 at 17:38:15 UTC, Swoorup Joshi wrote:
 Is garbage collection even useful besides managing memory?
Managing memory is GC's raison d'ĂȘtre.
Aug 09
prev sibling next sibling parent 12345swordy <alexanderheistermann gmail.com> writes:
On Wednesday, 9 August 2017 at 17:38:15 UTC, Swoorup Joshi wrote:
 On Wednesday, 9 August 2017 at 15:47:17 UTC, Guillaume Piolat 
 wrote:
 On Wednesday, 9 August 2017 at 13:46:29 UTC, MGW wrote:
 Memory allocation and deallocation when an application is 
 being completed in GC operates in FIFO sequence.
 Is there a possibility to shift GC memory deallocation to 
 LIFO mode?

 It`s connected with the fact that GUI library (Qt) creates 
 QApplication first,
 but GC destroys this object first when an application is 
 being completed. This leads to the application failure.
 If the sequence of memory deallocation on LIFO is shifted, it 
 will essentially simplify the cooperation with C++ libraries.
https://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors
Is garbage collection even useful besides managing memory?
That is like saying "Is fire even useful besides heating things up?". Alex
Aug 09
prev sibling next sibling parent Johnson Jones <JJ Dynomite.com> writes:
On Wednesday, 9 August 2017 at 17:38:15 UTC, Swoorup Joshi wrote:
 On Wednesday, 9 August 2017 at 15:47:17 UTC, Guillaume Piolat 
 wrote:
 On Wednesday, 9 August 2017 at 13:46:29 UTC, MGW wrote:
 Memory allocation and deallocation when an application is 
 being completed in GC operates in FIFO sequence.
 Is there a possibility to shift GC memory deallocation to 
 LIFO mode?

 It`s connected with the fact that GUI library (Qt) creates 
 QApplication first,
 but GC destroys this object first when an application is 
 being completed. This leads to the application failure.
 If the sequence of memory deallocation on LIFO is shifted, it 
 will essentially simplify the cooperation with C++ libraries.
https://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors
Is garbage collection even useful besides managing memory?
Of course! Once a week it is useful! Else things start piling up and getting really smelly! Not very healthy!
Aug 09
prev sibling parent Guillaume Piolat <contact spam.com> writes:
On Wednesday, 9 August 2017 at 17:38:15 UTC, Swoorup Joshi wrote:
 Is garbage collection even useful besides managing memory?
GC has the unique advantage of being a global owner, hence avoiding to encode ownership into types for memory (when you can use it).
Aug 10