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: 
adrianc1982
Level 7

check space used in roregistry

hey guys is there a way to check how much space of the 16kb is used by the roregistry?

another question is i would like to open 1000 slots to store the resume values of movies that have been watched, i also want to save the ones that have already been watched so im not deleting after theyve seen it.

can i get away by deleting the fisrt entry after 1001 entrys have been reached? each time i write a registry does it append it to the end? if i modify an existing registry does it appends to the end too?

Thanks.
0 Kudos
3 Replies
Komag
Level 9

Re: check space used in roregistry

The registry is a big Associative Array with all the values being Strings.
If you want to check the size, it's doable but tricky, and you have to manually add it all up
Access the registry with:
r = CreateObject("roRegistry")
Then you can get a list of all your sections with:
secList = r.GetSectionList()
secList is now just a regular roList, which you can use ifList, ifArray and ifEnum, so you can count the listings or do other stuff

As for the sections themselves, see http://sdkdocs.roku.com/display/sdkdoc/ ... trySection for details. If you know the size/length of the strings you'll be saving, you can manually keep track of your registry size by basically counting one byte per character, plus some extra bytes for headers. RokuMarkn gave some details here:
viewtopic.php?f=34&t=87869#p495737
"Well, it's a little complicated. Each registry entry stores the name and value, with a two byte header in front of each (so 4 extra bytes per entry). In addition there is a small header for each registry section (2 bytes plus the section name I think), and another header for the whole registry (about 30 bytes). However, the whole thing is zlib compressed before storing it, and it's the compressed file that is limited to 16K. This makes it rather difficult to predict exactly how much space you will be using. I'm not sure how knowing the exact size would be helpful, unless you're caching things in the registry that can be obtained elsewhere."

I imagine that if you accessed every single registry section and counted the characters of every single key/value (using Len(str)), and added the correct extra bytes for headers, you could come up with a reasonably close total uncompressed size.

I count the size of my keys and sections while saving the info, not later, but it might be helpful to be able to access that total number at any point, hmm.
0 Kudos
Komag
Level 9

Re: check space used in roregistry

Okay, I wrote and tested a function to count the currently used registry space:

FUNCTION getRegSize() ' trig by NONE
sz = 30 ' Header for the whole registry
r = CreateObject("roRegistry")
secList = r.GetSectionList()
FOR EACH name IN secList
sz = sz + 8 ' A small header for each registry section (2 bytes plus section name, assume 6 more bytes)
sec = CreateObject("roRegistrySection", name)
keyList = sec.GetKeyList()
FOR EACH key IN keyList
val = sec.Read(key)
sz = sz + Len(val) + 4 ' Headers - add 2 bytes for the key and 2 bytes for the value
END FOR
END FOR
? "Registry size" sz
END FUNCTION
0 Kudos
adrianc1982
Level 7

Re: check space used in roregistry

thanks for the heads up on how to do it Smiley Very Happy
0 Kudos