Jump to content

KVP holds less data per key than stated on wiki?


Quistess Alpha
 Share

You are about to reply to a thread that has been inactive for 848 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

So I did a simple test to see how much data I could cram into the value of a key-value pair, and got, considerably less storage than the wiki lead me to believe I should get:

string gsStorage;
default
{   state_entry()
    {   integer baseline = llGetUsedMemory();
        integer i = 110;
        while(~--i)
        {   gsStorage+="❤❤❤❤❤❤❤❤❤❤❤❤❤"; // 13 2-byte characters.
        }
        llOwnerSay((string)(llGetUsedMemory()-baseline)+"::"+(string)llStringLength(gsStorage));
        llUpdateKeyValue("Debug:Storage",gsStorage,FALSE,"");
    }
    dataserver(key ID,string data)
    {   integer success = (integer)data;
        if(success)
        {   llSay(0,"Success!");
        }else
        {   integer failure = (integer)llDeleteSubString(data,0,1);
            llSay(0,llGetExperienceErrorMessage(failure));
        }
    }
}

Attempting to store above 1400 2-byte characters (actually a bit less) results in an XP_ERROR_INVALID_PARAMETERS return value, but 1300~1350 works.

The amount of used memory heavily implies the characters are getting stored 2 bytes each. 1400*2=2800 and the wiki says I should be able to store 4095 bytes. What gobbled up the other 1295 bytes?

  • Like 1
Link to comment
Share on other sites

1 hour ago, Frionil Fang said:

"❤" is a 3-byte character though in UTF-8 (\xE2\x9D\xA4 according to a tool I asked). It would be 2 bytes in UTF-16, but not in UTF-8.

Hmm, so perhaps KVP is using UTF-8, and script memory is using UTF-16? ~1350 characters is indeed about a third of 4096 bytes.

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 848 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...