Raised This Month: $32 Target: $400
 8% 

Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]


Post New Thread Reply   
 
Thread Tools Display Modes
dubbeh
Senior Member
Join Date: Jul 2007
Old 11-29-2016 , 19:42   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #171

Just a quick update: I'm 100% sure something is leaking inside Dynamic when more than one collection is introduced.

If you only stick with 1 collection, the s_CollectionSize is right for the number of entries and MAXPLAYERS. When you start to introduce a 2nd collection or more. That value keeps getting bigger and bigger over time, with each concurrent map change.

Will attach the log files below for reference, simple LogMessage inside DynamicObject->Dispose() and grabbing sCollectionSize and GetArraySize(sCollection);

Only time the collection appears to cleaned completley is when OnPluginEnd is called and the garbage collector kicks in - The 500 or so entries is me not calling Dispose on OnPluginEnd (Going to fix that soon!)
Attached Files
File Type: zip Dynamic Tests.zip (11.9 KB, 62 views)
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-29-2016 , 22:43   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #172

https://github.com/ntoxin66/Dynamic/...ynamic.sp#L208

You can see the collection size only changes when objects are disposed at the end of the internal collection.

Eg. If I make 10 dynamic instances and dispose the first 9 the collection won't change size.

Your best to use the new handle usage command to track for leaks.
__________________

Last edited by Neuro Toxin; 11-29-2016 at 22:44.
Neuro Toxin is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 11-30-2016 , 19:24   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #173

Will run some more testing with 2 simple collections and see what i can come up with.

Tricky issue to discover, got a few ideas to test out though.
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 12-06-2016 , 08:31   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #174

Quick update: Made a simple plugin that causes the handle leaking and should hopefully make it easier to debug.

Been quite busy with RL recently and not had much time to test this problem. Got some free time now and will look into it more.

Can see while running this and using sm_dynamic_handles that data handles are leaking, the handle usage seems to be increasing by 8 on each map change (This is from building the latest commit on github).

Even utilising a very basic collection with just an int value, the problem was happening. If that helps anyone else.

Update:
Uploaded the latest Dynamic Collection Leak plugin to GitHub with a few small changes - All the members have unique names now for easier debugging, can be found here.

Also, added an update to Dynamic on local repository that includes a new command:

"sm_dynamic_members" - Prints all member names to the console - Get it here

Won't make a pull request for this until I'm happy with the code, bit messy with how it prints right now and wanted to make it give more info.

Update 2:
Made a pretty big discovery. Dispose doesn't appear to be getting called on anything over the first collection from simple log checking.

Spoiler


Found the problem, it appears that member.IsValid returns false on anything over the first collection inside collection.inc
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome

Last edited by dubbeh; 12-07-2016 at 09:25.
dubbeh is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 12-19-2016 , 03:40   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #175

Post a new reply if your updates are far apart so I can see.

I think I found the bug in the collection methodmap.


Code:
	public void Clear(bool disposemembers=true)
	{
		if (disposemembers)
		{
			int count = this.Length;
			Dynamic member;
			for (int i = 0; i < count; i++)
			{
				member = view_as<Dynamic>(i);
				if (!member.IsValid)
					continue;
					
				member.Dispose();
			}
		}
		
		this.Clear();
	}

Should be.

Code:
	public void Clear(bool disposemembers=true)
	{
		if (disposemembers)
		{
			int count = this.Length;
			Dynamic member;
			for (int i = 0; i < count; i++)
			{
				member = view_as<Dynamic>(this.Get(i));
				if (!member.IsValid)
					continue;
					
				member.Dispose();
			}
		}
		
		this.Clear();
	}
Can u test and push a pull request so I can merge the fix.
__________________

Last edited by Neuro Toxin; 12-19-2016 at 03:41.
Neuro Toxin is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 12-19-2016 , 12:41   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #176

Just ran a quick test with the change to collection.inc, Doesn't seem to solve the problem with the leaking (Made sure to re-compile everything too).

DCL plugin is showing a 4 handles increase per-map change. Havn't got the full base setup for logging right now after changing radio internal storage with the current problem.

Ran the members dump on local repository and It's showing that every collection member over the first is still leaking.
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 12-19-2016 , 16:43   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #177

You'll need to recompile ur test plugins not dynamic.
__________________
Neuro Toxin is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 12-19-2016 , 17:01   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #178

100% made sure to recompile the plugin and Dynamic. Going to re-add the logging stuff again over the next couple of days, and test if it's still showing invalid indexes when calling IsValid after the change above.

Think It's something else on top of that. Related to closing the ArrayList before it's completley disposed all data, which in-turn is corrupting the Get calls to the ArrayList collection, on subsequent collections.
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 12-19-2016 , 22:19   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #179

Say you add a collection to a dynamic object and then call dispose on the dynamic object. The collection will have CloseHandle called while leaving its members potentially leaked.
__________________
Neuro Toxin is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 12-20-2016 , 11:41   Re: Dynamic Objects and Properties - v.0.0.22 - [2016.11.21]
Reply With Quote #180

After some testing with the collection leak tester. Everything seems to be ok now with member counts.
Log output


Member count is staying at 70 which shows it's fixed. Good job!

Will revert the member names commit and apply the fix to local repository, then create a pull request soon.

Edit:
Pull request sent
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome

Last edited by dubbeh; 12-20-2016 at 11:50.
dubbeh is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode