View previous topic :: View next topic |
Author |
Message |
Ralf
Joined: 30 Aug 2007 Posts: 51 Location: munich
|
Posted: Mon Jul 27, 2009 9:26 am Post subject: Access violation with SHARENAME |
|
|
Hello,
I have tried to use the new feature to share common memory. But I had program crashes (with access violation) when I used an array twice with different sizes. See the following sample code:
Code: |
integer :: i
real*4,allocatable,dimension(:) :: a
allocate(a(3), SHARENAME="MyMemory2")
a(1) = 1.
a(2) = 2.
a(3) = 3.
write(*,*) a
deallocate(a)
allocate(a(2048), SHARENAME="MyMemory2")
do i=1,2048
a(i) = float(i)
enddo
write(*,*) a
end |
with the debugger I can see, that the array "a" shows "Illegal pointer" at position 1025 and further after the second allocate command. Is there a way to release also the sharename, when dellocating the array?
Thanks,
Ralf |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Mon Jul 27, 2009 7:47 pm Post subject: |
|
|
This needs some careful thought.
The general idea is that the memory will be released when all processes that share the memory have terminated.
To force the memory to be released may need a call of the form
call unmap_file@(loc(a))
but this is not built into deallocate because another process could be sharing the memory.
If you try to unmap the file in the code then this also causes problems.
Given a little more time, I may be able to come up with a sensible modification for the next release. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Mon Aug 31, 2009 12:36 pm Post subject: |
|
|
For the next release I have added a subroutine that you can call before deallocate.
In your code it will take the form:
Code: | CALL enable_deallocate@(a)
deallocate(a)
|
The new routine has the interface
Code: | C_EXTERNAL ENABLE_DEALLOCATE@ '__enable_deallocate' (REF)
|
|
|
Back to top |
|
 |
|