Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 10 Aug 2012 07:06 PM |
When the game starts it has somewhere around 1,000 bricks in it. It's a game where you can test pretty much all the Gear in the catalog.
After a couple of hours or days, most servers get around 15,000 bricks. I have a cleanup script that calls Instance::Destroy on all non-character instances in the Workspace every few minutes. So the bricks aren't in the Workspace. Where are they coming from, and how can I get rid of them? (Or should I even bother? The servers don't seem any laggier, because the bricks are just in memory, not actually colliding etc) |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 07:08 PM |
they'll probably be garbage collected soon after destroyed
but isn't your game pretty much a rip-off of the millions of other catalog testing games out there? |
|
|
| Report Abuse |
|
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 10 Aug 2012 07:09 PM |
"It's a game where you can test pretty much all the Gear in the catalog." I think most of us know that by now. ;)
I really don't know, if you're calling :Destroy, then I thought the garbage collector will get rid of them.
When you see a place with 15k parts, are there hats and such around? I'm not sure, but are you positive :Destroy removes all of the descendants. If you're removing the hat or tool, and it doesn't, that could be the issue. It's just a guess. I'd assume you'd see a ton of bricks with hat meshes laying around in that case.
Is there any latency?
"Improvise, Overcome, and Adapt." -Captain (RIP) |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 07:14 PM |
For some reason, all parts (including those in tools that are in your backpack) are counted as primitives, although they're not in the Workspace. I truly have no idea of why they're counted as primitives, but I know they are.
I suggest you make your cleanup script also destroy the parts and other things in the lighting and in the other services. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 10 Aug 2012 07:14 PM |
> but isn't your game pretty much a rip-off of the millions of other catalog testing games out there?
No... Have you even played the game?
> When you see a place with 15k parts, are there hats and such around? I'm not sure, but are you positive :Destroy removes all of the descendants.
Yes, the 'Destroy' method does call 'Destroy' on the descendants of the instance. The bricks seem to be parented in nil. I'm guessing it's just bad coding on the part of the Gear writers.
I even call 'Destroy' on the player's previous Character after he respawns. The only thing I can think of is that some instances are parented to nil but not being properly cleaned up. If there are no references to a part that exist outside of nil, shouldn't it be GCed (since it can't be recovered and it can't put itself back in the DataModel) |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 07:17 PM |
Don't worry about the garbage collector. It _DOES_ do its job, no matter how non-apparent that might be. The whole point of automatic memory management is that you don't have to worry about things that there are no references to. Just let it do its job and do yours, which is to remove these references.
Tell me, when you destroy everything, you indeed destroy every single thing except the characters, right?
I know you don't destroy the player's bases, but you destroy everything else than that, right? Including the scripts and all the rest... |
|
|
| Report Abuse |
|
|
| |
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 10 Aug 2012 07:19 PM |
function DestroyInstance(instance) if not ( instance.ClassName == "Terrain" or instance.ClassName == "Camera" or instance.Name:match("'s Cloud") or instance.Name == "MapModel" or game.Players:GetPlayerFromCharacter(instance) ~= nil ) then instance:Destroy() end end
while true do wait(300) for _, instance in pairs(Workspace:GetChildren()) do pcall(DestroyInstance, instance) end end |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 10 Aug 2012 07:20 PM |
| No I haven't checked Lighting but I don't think Gear add anything to lighting + I have stuff there and I don't want to remove it. |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 07:21 PM |
Yeah, you are only checking Workspace
look in game.Lighting for stuff too. It doesn't show up and doesn't collide with the world, so it's a great place to squirrel away things you want to clone. |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 07:21 PM |
| Yeah, there are gears that put things in lighting |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 07:22 PM |
Why ignore the camera? Just destroy it. It'll be re-created anyway...
Also, you should check the lighting. In fact, you should check every single child of the game. Who knows what gear can do? |
|
|
| Report Abuse |
|
|
3543
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 121 |
|
|
| 10 Aug 2012 07:33 PM |
local a = Instance.new("Part",Workspace) a.Name = "ThisIsAPart" wait(1) a:Destroy() while true do print(a.Name) wait() end
a is never garbage-collected because you still have and are using a reference to it.
I then used game:SetMessageBrickCount() to see how many bricks the game thinks it has. 1 brick, which would be the terrain. From this, I can tell that your problem isn't that the bricks aren't garbage-collected for any reason, but that the bricks actually exist. Might it be possible some gear is parenting stuff to lighting? Is it maybe the fact that they're inserting things with insertservice?
Testing that, confirms that it's possible.
By running this: game:GetService("InsertService"):LoadAsset(59524622) the brickcount increased. The more I tried it, the higher the brickcount went.
I further tested with insertservice with this line: for j, v in pairs(game:GetService("InsertService"):GetChildren()) do print(j,v) end This resulted in 89 lines of '## Model'
Your problem is probably the fact that some gears insert stuff. If you clear out insertservice, the brickcount will lower. for j, v in pairs(game:GetService("InsertService"):GetChildren()) do v:Destroy() end changed the brickcount back to one. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 10 Aug 2012 08:21 PM |
> Yeah, there are gears that put things in lighting
Such as...?
> Why ignore the camera? Just destroy it. It'll be re-created anyway...
Because I sometimes play the game in Play Solo and it's really annoying when that happens.
> is never garbage-collected because you still have and are using a reference to it.
Yes I know.
> If you clear out insertservice, the brickcount will lower.
Wow I was under the impression that Models created by InsertService were parented to nil... If this works I am grateful. :D |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 10 Aug 2012 08:29 PM |
| I went into one of my game servers and there were 129,378 instances in InsertService... O_________O |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 08:44 PM |
"for j, v in pairs(game:GetService("InsertService"):GetChildren()) do v:Destroy() end"
Game:GetService('InsertService'):ClearAllChildren()
There's a ClearAllChildren method for a reason. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 10 Aug 2012 08:59 PM |
| I'm not going to clear every random service. It's not like I'm expecting exploiters to put parts there. But I will definitely clear InsertService. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 10 Aug 2012 09:07 PM |
I tried:
game:GetService("InsertService").ChildAdded:connect( function(child) child:Destroy() end)
But that messed up my game. It seems like LoadAsset parents the asset in InsertService before returning a clone. So my code would obviously mess things up. I'm trying to figure out the best way of fixing this. Should I just clear insert service every 10 minutes or so? |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 11 Aug 2012 09:49 AM |
production code:
game:GetService("InsertService").ChildAdded:connect( function(child) wait(0) child:Destroy() end)
(I realize I could index child.Destroy once but meh)
It looks like loadAsset parents the original model into InsertService and then clones it and returns the cloned copy. So if I didn't have the wait(0) it don't work too good. |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 09:57 AM |
| Did you end up checking lighting? |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 11 Aug 2012 10:00 AM |
| Not yet. I will have to make a list of all the things NOT to delete in Lighting. |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 11 Aug 2012 10:01 AM |
| Gear should not be accumulating stuff in lighting though. I would be quite surprised if you find anything. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 11 Aug 2012 10:08 AM |
| Well probably a couple Gear do, but I'm probably not gonna bother unless there are gear that really spam up Lighting |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 10:12 AM |
Have you tried a GUI which displays the children of every service?
Also how are you counting the parts? |
|
|
| Report Abuse |
|
|