- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I have a question. Is there any fast way to deallocate a linked list or I have to to it manually?
A sort of DEALLOCATE(linkedlistname)
Thanks a lot
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming your list is made of POINTER and not ALLOCATABLE (which is almost certainly the case), you have to do it pointer by pointer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Steve,
thanks a lot. So, probably the my program is going to be slow comparing to a simple deallocate in case of pre-allocate vector or matrix.
What do you think?
Thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It all depends on what your program actually does. If it has significant work with data, the allocate/deallocate is not likely to be an issue. Before you spend any time worrying about this, make sure you have profiling data to back up your assumptions.
Note that if your list element has allocatable array components, deallocating the element will deallocate the allocatable components (but you're not saving any time doing this as the compiler would just be doing it for you.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If new list nodes are going to be allocated, then consider placing the list of nodes into a list of reusable nodes. This assumes that the nodes are of a nature that makes them reusable. You can place an entire list of linked nodes onto a free list at the cost of a single CAS (or DCAS). This is orders of magnitude less time than performing one DEALLOCATE.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, this discussion reminds me of yet another Fortran 2008 feature I'm waiting to get my hands on: allocatable components of recursive type! would love to see this in Intel Fortran soon! :-)

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page