Silverfrost Forums

Welcome to our forums

Access violation with SHARENAME

27 Jul 2009 8:26 #4825

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:

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

27 Jul 2009 6:47 #4828

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.

31 Aug 2009 11:36 #4912

For the next release I have added a subroutine that you can call before deallocate.

In your code it will take the form:

CALL enable_deallocate@(a)
deallocate(a)

The new routine has the interface

C_EXTERNAL ENABLE_DEALLOCATE@ '__enable_deallocate' (REF)
Please login to reply.