- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Are there any general rules one should follow for memory allocation/deallocation to improve the efficiency of garbage collection? For example,
allocate (a(50),stat=...
allocate (b(50),stat=...
deallocate (b)
deallocate (a)
presumably works like a stack. But does it buy you anything?
Bruce Gerdes
- Balises:
- Intel® Fortran Compiler
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
There's no good reason to deallocate things in a particular order.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Thanks, Steve. "Garbage collection" was a poor description of the phenomenon I'm considering. A better term would have been "heap fragmentation.".
While I've found it practically impossible to completely avoid heap fragmentation, I've always been able to find or create waypoints in the execution at which I can defrag the heap using I/O. Between those points, however, I often find myself fragging the memory with rubber arrays. If array needs to grow, I allocate a temporary pointer for an array with, say, double the size of the original; move the original array into the new one; deallocate the original; redirect the original pointer to the new array; and nullify the temporary pointer. Quite obviously, that leaves a hole where the original array used to be.
Is there aFortran "heap manager" which recognizes the existence of this hole? It seems that there must be somesuch form of monitoring, or Fortran would apparently be incapable of reusing deallocated memory. It may not actuallyuse the hole for new allocations, but it seems that if one deallocates all the memoryabove the hole,Fortran must somehow recognizethat the top of the heap is now at thebottom of the hole.
Operating on the hypothesis that Fortran keeps some sort of heap table,it seems that the most efficientdeallocation sequence would be from the top of the heap down. To do otherwise would create additional holes and therefore additional headaches for the heap manager.
Does this make any sense? Am I overcomplicating a much simpler operation?
Bruce
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Upon further reflection, the issue may have a very short answer. That answer might be, "IFort uses malloc and free," or, "IFort uses the Windows memory management functions."
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable