I have a script, written in JSFL, to find all textfields in a FLA's library and then changing the text. I do also extend flash to use a C class that I have written to cURL some data and then return it back to flash. The current issue is that in some files it takes a very long time and a lot of memory to complete the required command. It does not get "stuck" every time but it does seem to happen most of the time.
I do have a few conclusions that I have come up with:
- The call to the C function seems to never cause any kind of hang up so I dont think that the C function is a problem
- I do parse the data that comes from the C function and that doesn't seem to be a problem either
- The problem seems to be within the function that traverses through the library and finds all the textfields
- Another problem could be within saving some data to the document using "document.addDataToDocument", however I have reason to believe that is not an issue either which I will explain.
Since this script changes the text it also needs to keep track of what text was in the file originally. I do that by saving some data, as a string, to the document. Then when I run the command again and convert the textfields back to what they were I load the data from the document using "document.getDataFromDocument". After that is completed I save over the saved data with an empty string ("") in order to possibly remove some of that saved off data from memory. I'm pretty sure the "get" is not slow nor is the "add".
Most of the time (> 50%) the first time I convert is quick. However, most of the time when converting back to what text I had it gets "stuck". By "stuck" I mean memory usage starts to go up, all the way up to almost 7 GB when normally it run at or under 1GB. The function ends up completing but taking 5+ minutes when really it should only take about 10 seconds.
Here is some of the memory usage I printed out last time memory went up:
I dont understand the negative numbers. Also in this case I went from < 1GB memory usage up to 6.3GB using Windows Task Manager to view memory usage.
Windows 7 Pro Servic Pack 1 64 Bit
8 GB Ram
NVIDIA geForce GTX 560
If I could debug this somehow or print out what it is currently doing that might help me figure it out but since Flash ends up "not responding" while the script is running I can't see anything happening. I guess maybe I could write to a file over and over which I could view as it is running and now that I think about it that would help and I'll try that next.
In the meantime, does anyone have any idea as to what could be causing it to get "stuck" and elevate so high in memory usage? I have tried to optimize everything in the script as much as possible, without going to extremes.
If any of this doesn't make sense or you need more info please let me know.