-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested Dictionary conversion causes crash at exit sub #275
Comments
VBS-JSON probably is not a good match for your project due to the size of your Json and the fact that VBA-JSON builds an in-memory representation of the Json. For large Json processing investigate using PowerQuery (Excel 2016+), PowerQuery Desktop, SQLite with Json UDF, MySQL, Postgres or other SQL databases with Json processing capabilities. |
Would you possibly also have any suggestions regarding the creation and storage of nested dictionaries? Basically my situation is that I have a table with a series of recipes, and I want to both store that recipe data into a json file for faster data grabbing & the ability to preserve that data outside of excel / not require the data to forcefully regenerate every time I need to reference that data, and then afterwards create nested recipes from the same data which considers cases when an ingredient is an intermediate and has its own ingredients. Currently I have it set up where I create a dictionary / .json for the table data as standalone recipes, then I create a dictionary / .json for nested recipes using the prior dictionary as a data source. Eventually I want to be able to set it up where it can just read the .json file for grabbing the data over making a dictionary, and then create a flowchart inside excel which allows the user to swap between different recipes. |
@PlayfulPiano when you say that it crashes, do you mean the host application crashes (ie. Excel) or are you getting an error message and/or state loss? Also, do you have a reproducible example? |
Excel and VBA stop responding and I have to force close it. It's reproducible in that my code can generate the large json string, store the string, and print/ save the string to a file no problem at manual stepping, but the moment it steps out of the subroutine it stops responding. The data I use is otherwise sensitive. |
I should be able to upload the module code though tomorrow |
Hum, based on this, I would assume that there is a problem during the garbage collection phase. Maybe setting some of the dictionaries manually to nothing before the |
Here is the gist for my module & a custom class I created called ItemData. I am otherwise using the VBA-JSON module & the FastDictionary class. |
Oh, you are using VBA-FastDictionary? Does the crash occur when you use a regular Scripting.Dictionary or VBA-Dictionary? |
I didn't use the regular version / vba dictionary iirc because it was having trouble recognizing a part of my code, albeit I can't remember what it was exactly. For right now though, I'm instead just not going to store the tree dictionary at all as a .json and instead store the flowchart itself, which should be a lot less complex. |
Looking at the gist, there isn't anything that seems crash worthy in the code. Having sample data would make it easier to reproduce. |
I'm currently using the VBA JSON converter for a project I'm working on, but due to the size of the JSON string (the actual saved file is ~43kb), vba crashes after closing the subroutine which contains the converted string.
Note that it does properly print the converted string with no issues, it just crashes after leaving the sub which had the string stored. And what is being converted is a dictionary object whose values also are dictionaries, which could be nested a couple layers deep.
My assumption is that it's because the string length is too big, causing the memory to not properly remove it and leading to the crash. I tried to figure out how to make the converter either print after a specific string length or try to only have it convert each key at a time, but it either caused errors or formatting issues.
Does anybody know either how to adjust the JSON conversion module to setup batch printing after either a character length limit or having it print throughout the nesting process, so it isn't stored all at once?
The text was updated successfully, but these errors were encountered: