Memory keeps accumulating
BlitzMax Forums/BlitzMax Programming/Memory keeps accumulating
| ||
Hi. I have a process were I create an Element and than deletes it.. but it keeps accumulating memory. I dont know what im doing wrong or not doing right.. When I create an Element Method DeleteClass_Req(Class:ClassExtender_Class) ListRemove(Class.ClassElement.ElementClasses, Class) Class.OnRemoving() ClassManager.ReconnectClassFollowingParent(Class) 'ReconnectClassFollowingParentClass 'Sub Classes Deletion Local SC:ClassExtender_Class For SC = EachIn Class.SubClasses DeleteClass_Req(SC) ListRemove(Class.SubClasses, SC) Next 'Data Cells Delete ClassManager.DataCells.Del.DeleteClassDataCells(Class) Class.SubClasses = Null Class.DataCells = Null Class.ClassAnswersList = Null Class.MessagesList = Null Class = Null End Method Method DeleteClassDataCells(Class:ClassExtender_Class) Local DC:DataCell_Class For DC = EachIn Class.DataCells ClassManager.DataCells.Del.DeleteDataCell(DC) Next End Method Method DeleteDataCell(DataCell:DataCell_Class) ListRemove(DataCell.ParentClass.DataCells, DataCell) DataCell = Null End Method Type ClassExtender_Class 'Identity Field Name:String 'Private Name Field ClassTypeName:String 'The Offcial Name Recognizer Field info:String 'Info about the Command Field Location:String 'For MapEditor Available Classes Capture. (no need clone) Field Version:Float = 1 'Maybe Cancle// Field MadeBy:String = "Hardcoal" 'Family 'Element Field ClassElement:Element_Class 'The Element that this class belongs to 'SubClasses Field SubClassParentClass:ClassExtender_Class Field SubClasses:TList = CreateList() 'DataCells Field DataCells:TList = CreateList() 'Class DataCells. The Parameters of Class Field PEDC:DataCell_Class = ClassManager.AddDC_Element(Self) 'The Played Element DataCell. [Must be After DataCells.] ClassManager.AddDC_Element is Add DataCell 'Answers Field ClassAnswersList:TList = CreateList() 'Messages Field MessagesList:TList = CreateList () 'Flags 'User Changable Field IsTrigger_flg 'Means this Class is also trigger other stuff Trig Shoud be Called IF_ Field AsHitStyle_flg 'Continues or Hit. for now its for triggers but will be used for all classes maybe Field AvoidClone_Flg 'If this is set on the the clone ElementClone Command will ignore this class in clonning. Field WorkOnce_Flg Field IsActive_flg = True Field AutoPlaySubClasses_flg = False Field ShowAnswerIcon_flg Field CanBeAddedTo_flgs = 255 'Which Element Type Can Add This 'Followings Classes Field FollowingClass:ClassExtender_Class, FollowingClassName:String 'The Following Class Field FollowingClassOnTrue:ClassExtender_Class, FollowingClassOnTrueName:String Field FollowingClassOnFalse:ClassExtender_Class, FollowingClassOnFalseName:String 'Alba Stuff Field FlowChartClassAlElement:ALElement_Cls 'The FlowChart Class Window Field FCXPos = 100 'put fcxpos inside Field FCYPos = 100 Field PropsClassListAL 'The handle of Class Properties list 'Temps Field Icon_Handle 'This might be for mapeditor to be presented in flow chart.. 'still under test Field SubClassHandle1 Field SubClassHandle2 Field TriggerHitStyleOn_flag Field TriggerShoot_Flg Method New() Self.PEDC.Name = DefaultAffectedElementDCName End Method 'Abstracts Method PlayClass_Private:Object() Abstract 'The Class Play While Engine Run [Its object so it could return any value] Method OnBegin() Abstract 'Before The Play Start.. This Runs Once [Maybe Happen twice should be checked!] Method OnStop() Abstract 'When Play Game Stops Method OnAdding() Abstract 'When Adding this class to a new Element Method OnRemoving() Abstract 'When Removing From An Element Method WhileEditorMode() Abstract 'While Edit. Dont use stuff that cannot be removed so they wont stay after use. Maybe ill make Editor premade element stuff for use. 'Commands 'Maybe all commnads should be out side of class for faster copy. Method SetClassTypeName() 'Sets the Class Name [a must] Self.ClassTypeName = TTypeId.ForObject(Self).Name() Self.Name = ClassTypeName 'Make Rename mechanism maybe. End Method Method TurnOffClass(Remark:String = "") 'maybe cancle Self.IsActive_flg = False If Remark <> "" Then DbgMsg Remark + " At " + Self.Name End Method Method DeleteMainElement() GE.Element.Del.DeleteElement(ClassElement) End Method Method TurnOnClass(Class:ClassExtender_Class) 'A general Class Turn on Class.IsActive_flg = True End Method Method RefreshClass(WaitMouseDown = True) 'should not be here.. ME.Class.CrntClass.RefreshCurrentClass(Self) If WaitMouseDown Then UserInput.WaitMouseDown() 'ok End Method Method SubClassPlay() If Self.IsActive_flg Then PlayClass_Private() End Method 'Class Answers / Trigger 'This is like giving an order to a class so yo can make lots of stuff.. Method ClassShootAndAnswer(Answer:Object = "OK") 'you can use trigger shoot to pass information to the next class Local ClassAnswr:ClassAnswer_Class If Answer = Null Then Return TriggerShoot_Flg = True 'maybe cancle 'Sends Answers To DataCells For ClassAnswr = EachIn Self.ClassAnswersList 'Maybe ill make it shoot by type If ClassAnswr.DataCell <> Null Then ClassAnswr.DataCell.DataStrng = Answer.toString() ClassAnswr.DataCell.Element = Element_Class(Answer) ClassAnswr.DataCell.Value = Answer.toString().ToFloat() End If Next End Method Method ClassAnswerVal(Val:Float) Local ClassAnswr:ClassAnswer_Class TriggerShoot_Flg = True For ClassAnswr = EachIn Self.ClassAnswersList ClassAnswr.DataCell.Value = Val Next End Method 'Error Method ClassError(ErrorMsg:String = " On Class") DbgMsg ("Class Error: " + ErrorMsg + " Disabling Class " + Self.Name) Self.IsActive_flg = False End Method End Type here is some of my code.. Look at the delete Command and tell me please what am i doing wrong.. there must be a solution.. |
| ||
Ok i kinda solved it by nulling something. I don't understand why some inner stuff needed nulling and some don't in this case it was PEDC:DataCell_Class =null |
| ||
I don't understand why some inner stuff needed nulling and some don't Hiya, I would think you have some cyclic links. If you have parent -> child -> parent relationship ( which it looks like by browsing the fields of ClassExtender_Class) then the GC won't free them until the cyclic link is broken via setting one of them to null. It sounds and looks like that's what's happening here. |