What refers to this object?????????

BlitzMax Forums/BlitzMax Programming/What refers to this object?????????

Czar Flavius(Posted 2010) [#1]
I'm having memory leak woes. Something I've added recently is stopping my game objects from being collected, and I can't find out what. Is there some hack I can use as a debug tool to find out what refers to an object? Can I manually delete an object or at least make it garbage, so calling it causes an error? I know a "good design" prevents memory leaks, but this is a huge non-trivial project with lots of interconnectivity.


Czar Flavius(Posted 2010) [#2]
I'm also getting errors with a list sort, both objects to compare are turning up null. How do they even get in the list?


Dabhand(Posted 2010) [#3]
Unhandled Exception: Can't insert Null object into list

Type TType
	Field x:int
End type

Local list:TList = New TList

Local typ:TType = New TType
typ.x = 10

Print typ.x

typ = null

list.AddLast(typ)

For Local loop:TType = EachIn list
	Print loop.x
next


Null gets flagged in debug, ignored (In the EachIn loop) in release (BlitzMax 1.41)

Dabz

Last edited 2010


Czar Flavius(Posted 2010) [#4]
I am in debug mode!


Dabhand(Posted 2010) [#5]
Well, apparently, this is an old bug (null in lists), my code picks up the moment the null tries to enter the list, hence the message, you stated:-


How do they even get in the list?



Not to sound too prickly, but how do I know your in debug mode when you suggesting your null objects are in a list?

Your thread is that vague you dont even suggest what version of BlitzMax your using?

Any chance you can give everyone a chance to figure out what going on other than 'I am in debug mode'...

Dabz


Czar Flavius(Posted 2010) [#6]
I think it's caused by using tlinks to remove things The objects existed at some point but they were removed from a tlink and now they're null. To be honest I was just ranting and didn't expect anyone would want to help.


Dabhand(Posted 2010) [#7]
In that case, couldnt you just use a plain and simple test for Null before using anything?

As mentioned, this is/was an apparent known bug, which Gfk thought might have been fixed in 1.41 since it spat out a unhandled exception error.

Which was why I posted! :P


To be honest I was just ranting and didn't expect anyone would want to help.



Mmmm, odd reply, but, hey, never mind!

Dabz


Jesse(Posted 2010) [#8]
I hope you know about the bug in Tlist and sorting with an external function.


Czar Flavius(Posted 2010) [#9]
I don't. It's an external sort function. In fact, I put asserts in my external sort functon long ago as a matter of good practice, which is how I'm detecting these null objects. What is the bug?


Jesse(Posted 2010) [#10]
http://www.blitzmax.com/Community/posts.php?topic=90750#1032562

you are funny.

Last edited 2010


Czar Flavius(Posted 2010) [#11]
I thought that bug was just with compare methods and not compare functions?


Jesse(Posted 2010) [#12]
Nope!
as long as you are doing sorting inside Tlist with an external function it will break.

Last edited 2010


Czar Flavius(Posted 2010) [#13]
But I've been doing it for ages and it's only broke very recently??


Jesse(Posted 2010) [#14]
try backing up the module and modifying as suggested in the thread, recompile it and test. that will probably be the only way you are really going to know. I have been proved to be wrong often so I would give it a try to be sure.

Last edited 2010


Czar Flavius(Posted 2010) [#15]
The list issue isn't anything to do with the memory leak. I'd give my right arm to be able to manually delete an object right about now.