- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
I am trying to storedata to a file for saving memory, but the program uses more memory to read and write data. Here is a example, the program creates 400 MB memoryfor reading and writing. After the array is deallocated and the file is closed, there are still 200MB memory in the program.
!-------------------------------------------------
program test
implicit none
complex(8),pointer::A(:)
integer::N,i
open(1,file="test.txt",form='unformatted')
N=13000000
!2 MB
allocate(A(N))
!2 MB
do i=1,N
A(i)=real(i)
end do
!205 MB
write(1)A
!409 MB
rewind(1)
read(1)A
!613MB
deallocate(A)
!409 MB
close(1,status='delete')
!206 MB
end program test
implicit none
complex(8),pointer::A(:)
integer::N,i
open(1,file="test.txt",form='unformatted')
N=13000000
!2 MB
allocate(A(N))
!2 MB
do i=1,N
A(i)=real(i)
end do
!205 MB
write(1)A
!409 MB
rewind(1)
read(1)A
!613MB
deallocate(A)
!409 MB
close(1,status='delete')
!206 MB
end program test
- Balises:
- Intel® Fortran Compiler
Lien copié
3 Réponses
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Deallocated memory generally does not cause the virtual memory used by a running program to decrease - that memory is in a pool available for future allocations, but the OS believes it is in use.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Thank you. sblionel!
My question is why the program creats memory for reading and writing. It makesmy computer need more memory to run. If my computer doen't hasenough physical memory, the disk will be used for swapping and it will run slowly.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
I think the run-time library allocates its own buffer for the record.

Répondre
Options du sujet
- 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