dev:reference_counting
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
dev:reference_counting [2014/02/08 21:32] – converted doc/ReferenceCounting.html Credit:Mohamed Fawzi oschuett | dev:reference_counting [2014/02/08 22:11] – oschuett | ||
---|---|---|---|
Line 29: | Line 29: | ||
===== Sample code ===== | ===== Sample code ===== | ||
Some sample code to get a feeling of how it works... | Some sample code to get a feeling of how it works... | ||
- | < | + | < |
! create the matrix structure | ! create the matrix structure | ||
- | call cp_fmstruct_create(my_struct, | + | |
! create some matrixes | ! create some matrixes | ||
- | call cp_fm_create(new_matrix_1, | + | |
- | call cp_fm_create(new_matrix_2, | + | call cp_fm_create(new_matrix_2, |
- | call cp_fm_create(new_matrix_3, | + | call cp_fm_create(new_matrix_3, |
! get rid of the matrix struct as we do not need it anymore | ! get rid of the matrix struct as we do not need it anymore | ||
! (the matrix do, but they should look after themselves) | ! (the matrix do, but they should look after themselves) | ||
- | call cp_fm_release(my_struct) | + | |
! work with the matrices | ! work with the matrices | ||
Line 46: | Line 46: | ||
! get rid of the matrixes | ! get rid of the matrixes | ||
- | call cp_fm_release(new_matrix_1) | + | |
- | call cp_fm_release(new_matrix_2) | + | call cp_fm_release(new_matrix_2) |
- | call cp_fm_release(new_matrix_3) ! my_struct gets deallocated only here | + | call cp_fm_release(new_matrix_3) ! my_struct gets deallocated only here |
</ | </ | ||
- | < | + | < |
subroutine my_env_set_matrix(my_env, | subroutine my_env_set_matrix(my_env, | ||
type(my_env_type), | type(my_env_type), | ||
Line 84: | Line 84: | ||
===== References ===== | ===== References ===== | ||
* Geamma et al., Patterns (Reference counting, I think) | * Geamma et al., Patterns (Reference counting, I think) | ||
- | * Cocoa uses reference counting and there have been a couple of articles on it. They discuss retain cycles, but also auto-release pools, an extension to reference counting to be able to return temporary objects. This is not implemented in cp2k and hopefully avoidable (seeing the kind of code that there is in cp2k) | + | * Cocoa uses reference counting and there have been a couple of articles on it. They discuss retain cycles, but also auto-release pools, an extension to reference counting to be able to return temporary objects. This is not implemented in cp2k and hopefully avoidable (seeing the kind of code that there is in cp2k). |
- | * [[http:// | + | |
- | * [[http:// | + | |
- | * [[http:// | + | |
- | | + | |
dev/reference_counting.txt · Last modified: 2020/08/21 10:15 by 127.0.0.1