A PRIVATE ALLOCATABLE pointer variable that is allocated in a parallel region must be freed by the end of the region.
A separate copy of a PRIVATE variable is allocated for each thread on entry to a parallel region. At the end of the region, the variables are destroyed. If the variable is an ALLOCATABLE pointer variable, then the storage must be freed before leaving the region to avoid leaking memory.
ID |
Observation |
Description |
---|---|---|
1 |
Memory leak |
The place region was exited without freeing the ALLOCATABLE pointer |
integer :: OMP_GET_THREAD_NUM integer, pointer :: ptr integer, pointer :: a(:) call OMP_SET_NUM_THREADS(2) allocate(ptr) allocate(a(2)) ptr = 5 print *, ptr !$OMP PARALLEL PRIVATE(ptr) SHARED(a) allocate(ptr) ptr = 3 !$OMP CRITICAL a(OMP_GET_THREAD_NUM()+1) = ptr !$OMP END CRITICAL !$OMP END PARALLEL print *, a end
Copyright © 2010, Intel Corporation. All rights reserved.