Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Oak-Beard
Visitor

monitoring the refcnt

Is it possible via the debugger to print the refcnt for an arbitrary variable? If I put a stop statement in my code the debugger will show the refcnt for the immediate scope:
 
Local Variables:
cpx roAssociativeArray refcnt=4 count:20
global rotINTERFACE:ifGlobal
m roAssociativeArray refcnt=5 count:11
port <uninitialized>

The problem is that if i want to examine the contents of one the roAssociativeArrays I won't see the refcnt of it's contents. For example, i have defined an array 'cpx' that has as one entry a roScreen. Printing the array will not provide the 'refcnt' for the screen:

BrightScript Debugger> print cpx
grid: <Component: roAssociativeArray>
port: <Component: roMessagePort>
activeslotcnt: 3
screen: <Component: roScreen>

Is there any way I can get this info?
Thanks
0 Kudos
3 REPLIES 3
Rek
Visitor

Re: monitoring the refcnt

"Oak-Beard" wrote:
Is it possible via the debugger to print the refcnt for an arbitrary variable? If I put a stop statement in my code the debugger will show the refcnt for the immediate scope:
 
Local Variables:
cpx roAssociativeArray refcnt=4 count:20
global rotINTERFACE:ifGlobal
m roAssociativeArray refcnt=5 count:11
port <uninitialized>

The problem is that if i want to examine the contents of one the roAssociativeArrays I won't see the refcnt of it's contents. For example, i have defined an array 'cpx' that has as one entry a roScreen. Printing the array will not provide the 'refcnt' for the screen:

BrightScript Debugger> print cpx
grid: <Component: roAssociativeArray>
port: <Component: roMessagePort>
activeslotcnt: 3
screen: <Component: roScreen>

Is there any way I can get this info?
Thanks


Once in the debugger, you can assign an element of the AA to a temporary variable then use the `var` command to print the variables again. Something like:

BrightScript Debugger> myVar = cpx.grid
BrightScript Debugger> var


That should now print 'myVar' with a refcnt (increased by 1 for the local var).
0 Kudos
Komag
Roku Guru

Re: monitoring the refcnt

Wow, that's quite a nice trick to know 8-)
0 Kudos
Oak-Beard
Visitor

Re: monitoring the refcnt

Thanks! This is exactly what I needed. Very very useful 😄
0 Kudos