ryobg / JContainers

JSON-based data structures for Papyrus - the TESV Skyrim SE scripting language
MIT License
107 stars 23 forks source link

Filling a JArray casuses "Warning: access to a non-existing object with id 0x1 (1)" #117

Open MathiewMay2 opened 5 months ago

MathiewMay2 commented 5 months ago

I have a function that fills a JArray with the content of a a bunch of JSON files, about 6500 elements need to be placed in the JArray, but after 600 elements it gives this error "Warning: access to a non-existing object with id 0x1 (1)" is there a limit to how many elements a JArray can contain? i thought it was limited to 64 bit unsigned, this is my function

string[] mappingFiles = JsonUtil.JsonInFolder(mappingsPath)
    int i = 0
    While (i < mappingFiles.Length)
        string jsonPath = mappingsPath+"/"+mappingFiles[i]
        string[] mappingMembers = JsonUtil.PathMembers(jsonPath, ".string")
        int x = 0
        While (x < mappingMembers.Length)
            JArray.addStr(mappingHashKeys, mappingMembers[x])
            ConsoleUtil.PrintMessage(Jarray.getStr(mappingHashKeys, x))
            x += 1
        EndWhile
        i += 1
    EndWhile

Used in combination with PapyrusUtil, and i know for a fact the error does not come from PapyrusUtil since it is able to print all of the 6500 elements in the console fine the error only appears when i do JArray.addStr, same error with JMap. the JArray is defined in a separate function as "int mappingHash" and "mappingHash = JArray.object()"

SilverIce commented 4 months ago

@MathiewMay2 this most likely means that that while loop takes longer than 10 seconds. I assume nobody owns/references mappingHashKeys object and JC assumes that mappingHashKeys is garbage and it gets deleted.

Does this mappingHashKeys object is owned by something? Like JDB or another container or you have retained it? - that would help

SilverIce commented 4 months ago

https://github.com/ryobg/JContainers/wiki/Lifetime-Management