BOster
Legendary Poster
When I have used jde cache in my applications I usually name it Bxxxxxxx_[Job Number], where Bxxxxxxx is the Business function name and [Job Number] is a unique number using the internal next number. When I do this the cache is unique for each call and if needed I simply pass around the job number to other BSFNs that access the cache. I also allways, at some point, destroy the cache with a jdeCacheTerminateAll call or make sure that the number of jdeCacheTerminate calls match the number of init calls.
The MBF design of using cache says you never destroy the cache, instead job number is used as a field in the cache and when you are done with the cache you clear the records using a jdeCacheDeleteAll using the job number index. In order to not destroy the cache the number of jdeCacheInitMultipleIndex calls must be at least 1 higher than the number of jdeCacheTerminate calls and jdeCacheTerminateAll is never called. So my understanding of the design pattern for MBFs (or any other bsfn that does not destroy the cache) is as follows:
BeginDoc Function
jdeCacheInitMultipleIndex
EditLine Function
jdeCacheInitMultipleIndex
[do stuff]
jdeCacheTerminate
EndDoc Function
jdeCacheInitMultipleIndex
[do stuff]
jdeCacheDeleteAll [using the job number index]
jdeCacheTerminate
Now to my question:
Since BeginDoc will be called multiple times the number of jdeCacheInitMultipleIndex calls will continue to grow in relation to the number of jdeCacheTerminate calls. Will this cause any kind of memory leak over time? I know there is an internal counter that increments everytime init is called and decremented every time Terminate is called but this counter will continue to increase every time BeginDoc is called. Is there a maximum that this counter can reach? What happens if it does? Is the design pattern I layed out above correct or is there some pattern that makes sure the number of init calls is only 1 higher than the number of terminate calls?
The MBF design of using cache says you never destroy the cache, instead job number is used as a field in the cache and when you are done with the cache you clear the records using a jdeCacheDeleteAll using the job number index. In order to not destroy the cache the number of jdeCacheInitMultipleIndex calls must be at least 1 higher than the number of jdeCacheTerminate calls and jdeCacheTerminateAll is never called. So my understanding of the design pattern for MBFs (or any other bsfn that does not destroy the cache) is as follows:
BeginDoc Function
jdeCacheInitMultipleIndex
EditLine Function
jdeCacheInitMultipleIndex
[do stuff]
jdeCacheTerminate
EndDoc Function
jdeCacheInitMultipleIndex
[do stuff]
jdeCacheDeleteAll [using the job number index]
jdeCacheTerminate
Now to my question:
Since BeginDoc will be called multiple times the number of jdeCacheInitMultipleIndex calls will continue to grow in relation to the number of jdeCacheTerminate calls. Will this cause any kind of memory leak over time? I know there is an internal counter that increments everytime init is called and decremented every time Terminate is called but this counter will continue to increase every time BeginDoc is called. Is there a maximum that this counter can reach? What happens if it does? Is the design pattern I layed out above correct or is there some pattern that makes sure the number of init calls is only 1 higher than the number of terminate calls?