ID:141901
 
Code:
//Again nothin for you sorry =P


Problem description:
I don't know if any of you read that other problem I had, but I've narrowed it down to hitting the object limit.

Problem is, I keep hitting it. I've tried changing the system to use a single object to create multiple overlays and what not, but I still hit it. And I use a world set of objects rather than give each player their individual set of items, just to save. AND I STILL HIT IT.

So:
1. Just what the hell is the object limit? (I want a # or at least estimate)

2. Any other tips there are to cutting down on objs?

Edit:
3. Do deleted objs count towards the overall count? Becuase if so then that would explain a looooot. Hence why games where you punch... say a dummy for stats all day would have no problem with it, but mine where you have to use techniques and what not would.
The object limit is 65535 (216-1). To help you on your problem, we'll probably need more info one what you're doing.
In response to Popisfizzy (#1)
O,o nice,

Anyway as far as what I'm doing? Well before the bug would take a few days to do. With no reboot and what not, and it'd cause some verbs to go poof.

So before it took days worth of objs to reach the limit.

Now I've been adding text names above the character and HP bar below. But for these I've been using 1 object to create the entire name (editing the icon_state and pixels and adding it again)

So it's now reached in a few hours. The reason I don't get it are because of:

1. Before it took days, ok, but why? Hardly any objects are kept, everything gets deleted eventually.

2. I'm only adding 1 obj for the HP bar, and 1 obj for names. Not a huge increase. Also, when monsters die, the next spawn gets their objs from the one that died. So its even a recycling system.

The main problem would most likely be the OverlayReset(). I use it to reconfigure all the overlays that should be there and remove what shouldn't and what not. Problem is, for some reason, it detects NO obj's in the overlays, which means I'm forced to remove everything, but no objs get deleted because it doesn't detect them at all =\. And since it's not detecting objs, the name and such must be reapplied to the character, because I can't single out objs that should be kept.
VcentG wrote:
2. Any other tips there are to cutting down on objs?

Well, generally use less. For example, try to reuse existing objs as possible - if you're using screen objects, the same objs can be used and displayed on all of your player's screens. A common and overseen problem is people often creating new sets of screen objects for each player, even when they're identical. If you have tons of objs on the map, you could also unload unused areas of it, etc, same thing that's done to deal with turf limits and other things.

It's hard to be specific when you're not telling us how you're really using in your game. And there are a lot of ways to use objects in a game, it could be added up from multiple different, unrelated places in your code, or at fault of a specific problematic code. One line is generally enough to possibly hit an object limit, so it's not so hard to accidentally do a mistake and create too many objects.
turf/var/obj/O = new


You'll want to read this good article on managing resources and objects. It covers list and also does objs, but it's really a similar thing with all kinds of objects* - they're all limited (to the same number, 32k, except custom datums, which are limited to ~16 million, and turfs which have a more complex limit that isn't a given number of instances, but generally it is very big). There are separate limits for mobs, lists, strings, images, and more.

3. Do deleted objs count towards the overall count?

No. Only obj instances. That means only objects currently existing count for limits. So you could unload objects for when they're not needed to save on 'slots' (and also memory).
In response to VcentG (#2)
VcentG wrote:
1. Before it took days, ok, but why? Hardly any objects are kept, everything gets deleted eventually.

Well, not magic about it. Something changed in your code or something else related to the game that worsened the problem. >_>

2. I'm only adding 1 obj for the HP bar, and 1 obj for names. Not a huge increase. Also, when monsters die, the next spawn gets their objs from the one that died. So its even a recycling system.

Those kind of numbers wouldn't be related to the problem, yes.

The main problem would most likely be the OverlayReset(). I use it to reconfigure all the overlays that should be there and remove what shouldn't and what not. Problem is, for some reason, it detects NO obj's in the overlays

Overlays: The individual items in the list may not be directly accessed, since they are stored in a special internal format.
The overlays list doesn't contain actual atom objects, and you're not meant to access the values in it, by looping through it or otherwise. Basically, you can use it as you can a regular list (the list operators, procs, vars...), but you can't access or tinker with (not much, anyway) with the values inside. A proc to rebuild overlays is a common design for this.
Why do you think this proc is the problem? Does it generate a *lot* of objects? Well, if you think it's the problem, let us see it please so we can check it out. =P
In response to Kaioken (#4)
Pfft nevah, it just resets everything. All overlays go bye bye. However, there were a few things that it'd create new objs for. So I changed it (just like a few hours ago) to use 1 item for everything. So we'll see how that works.

Not to sound lame, but if I can't fix this I only need it to not reach the limit within 24 hours, since there's a auto-reboot at midnight DX.

Oh and I'm posting everything I use them for in a reply to that other message you said XP

Edit: The reason I say this obj would be the focus of a problem is that its called a plethora of times, when needed of course, but as you said, I can't access individual items, so I have no option but to redo everything. Which is why it would be a problem. Or atleast be able to seem like one.
In response to Kaioken (#3)
Yeah I know >.>. I'm cutting down I changed the entire inventory system. Now I have to change the technique system but thats going to be a loooot more work lol.

Anyway, Object Uses:

HUD (Each player gets their own, so yes I'll change)
Technique List (Showing what they have, the level of it, the req)
Techniques (uhh attacks that fire? XD)
Overlays (all are formed from 1 obj)
Name/Guild above char (each player gets 1 obj which is used to make the entire setup)
HP bar (same as above)
Inventory (But there's a world set of objs, the actual players don't have any items only a variable for a # of how many they "have")

And that's pretty much it...

HUD and Technique Tab are all thats left to change really. HUD will be fairly easy, but techniques ;-;. I'll have to change the entire system of learning and everything. For one, each tech will need a variable for uses. Which is like another 140 variables...Then there's the matter of the actual level of the technique... another 140 variables... >_> save meeeeeeeee
In response to VcentG (#6)
VcentG wrote:
Techniques (uhh attacks that fire? XD)

Projectiles, you mean. =P But those aren't really constantly created, they're quite temporary, so they're probably not so much a problem.

HUD and Technique Tab are all thats left to change really. HUD will be fairly easy, but techniques ;-;. I'll have to change the entire system of learning and everything. For one, each tech will need a variable for uses. Which is like another 140 variables...Then there's the matter of the actual level of the technique... another 140 variables... >_> save meeeeeeeee

If it's too much a problem and less efficient to share the objects for displaying Techniques, you could leave it as is - it shouldn't be such an obj sink anyway, I guess. As I said before, the problem might actually be a small piece of overlooked code or some such, so it's important to check everything if you can.
In response to Kaioken (#7)
Yeah I looked for your turf/var/obj/ etc stuff but didn't find anything of the sort, of course i checked mob and etc stuff too.

Edit: Oh and quests, also use objs. That's kinda medium, because there are properties that go along with them but not as crazy as techniques.

So I guess changing the HUD and Quests is my only option really.

Hopefully that'll be enough or I'm fawwwwked.
In response to VcentG (#8)
Optimizing existing code is always good, but I suggest trying to find the specific problem instead of going bonkers over all of your code! You should gather information first. :P You could put some debugging code into your game to count the objs used by each 'system' and some such, and try to track what uses the most objs. You could look through all objs with a for() loop, or override New() to increase a counter or some such, etc.

How exactly to do it varies on your systems' code, of course, but here's a general example. After you hit the obj limit, run a verb like this that checks the currently instantiated objs:
mob/verb/Check_Objs()
var //counters
hud_objs=0
tech_objs=0
proj_objs=0
other_objs=0
for(var/obj/O) //loop through all objs in the world
if(istype(O,/obj/technique))
tech_objs++
else if(istype(O,/obj/HUD))
hud_objs++
else if(istype(O,/obj/projectile))
proj_objs++
//...
else
other_objs++
src << "hud objs:[hud_objs]\n\
tech_objs:
[tech_objs]\n\
[...] other_objs:[other_objs]"

As you can see, nothing complex at all. The only hard part could be identifying which obj belongs to each 'system' or which code creates it, but for a lot of things you could distinguish by the type path - for others though it might be less simple. There are more things you could do as well, of course - here is a tad more specific statistics output:
mob/verb/Check_Objs_by_Type()
var/list/obj_types = new //this is an associated list
for(var/obj/O)
/*[add the obj's type to the list if it's not already
there, and] increase the number value associated
with that type in the list.*/

obj_types[O.type]++

//display the list to the player
for(var/path in obj_types)
src << "[path]: [obj_types[path]] instances"


EDIT: Damnit, I'm too used to writing 'elseif' with no space like in some other languages. >_>
In response to Kaioken (#9)
XP lol, I do elseif too sometimes.

Anyway thanks I'll give it a go. Watch it be something dumb >_>'

Your verb is nice, I just added a little to it and such. So far, when the game boots there's already 1600ish objs. Which Isn't completely bad. Because there were like 5 players, so thats hp, quests, hud, etc etc. Plus NPCs and such. and so far its gone up and there's only 2k so.... I guess it'll take quite a few hours to see the actual problem.
Bumping the topic to reveal new... info

hud objs:45
tech_objs:288
actualtechs:0
cloth_objs:32
quest_objs:77
hp_objs:534
wtext_objs:156
btext_objs:200
rtext_objs:176
otext_objs:9
gtext_objs:45
other_objs:527
total:2089

As you can see... ITS NOT THE OBJECT LIMIT. Maybe proc limit? or something? DX I dunno! but that was my only lead. And now I'm back out into the blue.

Here's more info on what it does:
1. People that log on are naked (aside from swords for whatever reason O,o)
2. They lose ALL technique verbs, except ones that come from equipping the sword. They also lose normal verbs. I even lost my admin verbs lol, AFTER loading my character. My admin verbs are given as soon as I log on, and thus I had them, and loaded and lost.
3. It instantly fixes through a reboot (although the verbs only come back because I coded them to do so)
4. Basically overlays get fawked, and verbs go with them. Other than that there're no other repercussions.

Edit:
5. Oh and before I believe SOME people lost some items from their inventory. But since I changed the system, no way that'd happen since, there is no inventory XD.

The reason I initially thought the obj limit is because it happened when I added the name overlay and all that other crap, which in the beginning each letter was 1 obj, it was a lot of objs. But the limit is what? 65k that Pop posted, and I have 2k, I'm nowhere near it.
In response to VcentG (#11)
Sounds like you hit the list limit, and BYOND is compensating by messing with lists. Make sure you don't initialize lists under every turf, and delete them when they aren't being used.

turf/var/this_would_crash_the_game_if_there_were_65535_or_more_turfs = list()
In response to Jeff8500 (#12)
Hmm I don't have that.

But what about mob lists?

I have 6 mob lists, that're like that.

And I never delete lists after verbs and stuff are done with them. So that would eventually back up and cause the overflow right?

D: Sounds more probable, seeing as verbs is a sort of list, as is overlays, which explains why they get messed up when its hit.
In response to VcentG (#13)
You should check how many lists you have periodically, maybe. If you don't delete lists that you define and initialize, it could be a problem (if it belongs to a deleted object, it counts as deleted). It could also be a text string overflow, those could be common with bad resource managing and long running games.
In response to Jeff8500 (#14)
Text string overflow? A little more on that? o,O

Like a message limit?
In response to Jeff8500 (#14)
I'm pretty sure it'd be a list limit. Since I added a verb to check, and there are 4k and some lists as soon as it starts. No players or anything. I wasn't even logged on O,o.

I got the lists down to 1k. And it goes up by 2 per monster mob. So I'm assuming that those are overlays and underlays?

Also it goes up by 4-5 per player because there are player lists. Before I had them as just mob lists, so all the monsters were getting them as well and they aren't even using em XD.

564 mobs in the world.

And the number starts off in the 1k zone. So it's generally 2 per.
In response to VcentG (#15)
Lists that count towards the limit are user defined; overlays etc. don't count. If you have, let's say, an attack list, that would count, though. Also, if you have mob/var/list/Hax = new and mob/var/list/stuff = new, that will add two per mob. Text string overflow is exactly what it sounds like, having 65535 or more text strings in the world (mob/var/thing = "this is a text string that is saved").
In response to Jeff8500 (#17)
Hmm, the only text strings I use in that sense are like 5 per mob.

To have them unsave from the world I can just set them to null or something?

And does that count obj suffixes?
In response to VcentG (#18)
I'm unsure on object suffixes; that might count. And it's not unsave, it's delete :P. But yeah, setting a variable to null would delete the text string. It's usually better to use numbers, rather than text strings, then have a proc to translate for you.

#define LEAF 1
#define SAND 2
#define MIST 3

proc/village2text(X)
switch(X)
if(LEAF) return "leaf"
if(SAND) return "sand"
if(MIST) return "mist"


It's much more memory conserving, as well, because usually text strings created by that would just be used to display things for the user (they would be very short lived, in other words).
Page: 1 2