Reflections possible memory leak
Archives Forums/BlitzMax Bug Reports/Reflections possible memory leak
| ||
I'm not 100% sure, but is there any reason the method TTypeId.ForObject(Null) should increase the memory used (GCMemAlloced()) by around 30000 Bytes? No? Tought so. It gets even stranger by the fact, that this memory increase is only done once, so it does only happen once during runtime. Finally, some code (Note that you can simply use TTypeId.ForObject(Null), too, it doesnt matter) Type TBlubb Field Gaga:Byte End Type Local Blubb:TBlubb = New TBlubb GCCollect() Print GCMemAlloced() TTypeId.ForObject(Blubb) GCCollect() Print GCMemAlloced() So long, Kernle |
| ||
I haven't looked into the source of the reflection module but perhaps it's possible that some static field is being filled with data that increases the memory usage, which doesn't get freed afterwards. Which is understandable if it's a static field (Global). |
| ||
Finally, some code This is not a good example. For a proper test you need have it run over a period of time, to allow the memory allocator to balance out. You will tend to see the memory increase for a while before it levels off. (If it always increased, no matter what, then yes, I would have to agree that there was a leak). SuperStrict Type TBlubb Field Gaga:Byte End Type Const total:Int = 10000 Local count:Int = 0 For Local i:Int = 0 Until 1000000 Local Blubb:TBlubb = New TBlubb TTypeId.ForObject(Blubb) count:+ 1 If count = total Then count = 0 Print GCMemAlloced() End If GCCollect() Next GCCollect() Print GCMemAlloced() |
| ||
Type reflection infomation is generated by demand, it will be kept after that. |
| ||
What kind of reflection data is that supposed to be? And why does it need to be kept in memory? |
| ||
And why does it need to be kept in memory? So it's faster when you use reflection for stuff later. |