Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Oak-Beard
Level 7

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
Rek
Level 7

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
Level 9

Re: monitoring the refcnt

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

Re: monitoring the refcnt

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