I found a small problem with extending the maximum capacity for actors, classes, weapons, etc. in the editor. Although it works, there is a limitation on how many objects can be added at one time using the "Change Maximum" method.
I found that when you try to increase the capacity by much more than 1,000 at a time, the application will crash. I capped the maximum size at 9999, but it is not possible to simple go from say, 200 actors, to 2,000 or more without a crash. It works fine if you add 1,000, which will simply cause an expected second or two of lag while the Actor objects are being created and the list is being populated.
I don't if this information is pertinent or not, but 1,000 actor objects translates into roughly 10 MB of RAM.
I don't follow
are you saying that the lag caused by creating 1,000 new actors at once causes a crash? or that there simply being 1,000 actors causes a crash?
No, can create as many as you want, just so long as it not much more than a 1,000 at a time.
I just committed, so update and see what I mean in the test solution.
you need to not update the list box as you are adding the actors
make a method to refresh the list box and call it AFTER all the actors have been added
also it may be better to use list comprehension and make use of the extend method to add the actors to the list
if newMax != currentMax:
if newMax > currentMax:
newactors = [Actor() for i in range(newMax - currentMax)]
Project.Data_actors.extend(newactors)
and then refresh the actors listbox
similarly for removing actors instead of looping and popping them out use the del statement and use a slice
if newMax != currentMax:
if newMax > currentMax:
#add actors
else:
del Project.Data_actors[newMax:CurrentMax]
now that particular slice may be offset from the slice you want by 1 index so you probably need to check that
all in all this should be faster and result in no crash.
Alrighty, that seems better.
I'm still learning Python as I go, so please let me know if you notice any other things for me to improve on. There are still basic functions such as slice which I haven't even used yet :P
I take it after doing all that it didn't crash when adding more than 1000 actors/
I got it to crash before by adding 5000 actors at once will it still crash?
Actually, its still about the same.
I added 5000 actors, and so long as you don't try to click the window or anything, it won't crash, but it took 24 seconds, and my computer is not slow by any means.
I do have an idea. We can not initialize new actor instances while the list is being populated, but maybe use it more like a just-in-time function. If the selection is changed, check if anything exists in the corresponding container, and if not create it. This could cause issues when the data is supposed to be saved, but so long as we handle it properly, it should work.
EDIT:
I implemented it, and it can now fill the list with 9,999 items in less than a second. Data_actors is extended with a None, which can simply work as a placeholder for Actor, which can be initialized only when it needs to be, but it will keep track of the size of the container. So far, this looks to be the best way for performance. It may require a few more checks throughout the code to make sure items exist before accessing them, though.
sounds good. we should do the same with everything initialize it with None and check to be sure it isn't none before we do anything with it
Is this a problem that could prevent us from having 9999 actors or anything else for that matter? I'm also a bit concerned about the memory usage. 10 MB for 1000 actors would means that an actors needs 10 kB which is unrealistic.
no it just prevents that many from being created at once you can still have 99999 actors. as for the memory usage, now that I think about it there is no way that one acotr instance freshly created is 10 KB, that's impossible. but if that's the case we should probably look into a deferred loading option and try to only hold the data in memory that is actively being worked on. storing the rest in a temp folder.
The RAM usage may not be the most accurate.
I just happen to have Task Manager open to the process tab, and noticed every time I added 1,000 actors, the "Memory (Private Working Set)" value would increase by 10 MB, give or take about 200 KB.