Comments (7)
Hi all
@megamarc
The 1044 byte memory leak can be seen in the log:
Tilengine v2.4.0 64-bit built Nov 17 2019 19:51:47
Tilengine: bitmap created at 0x5555555cebb0, 23720 size
Tilengine: palette created at 0x5555555ce6a0, 1044 size
Tilengine: spriteset created at 0x5555555caf10, 312 size
Tilengine: sequence created at 0x5555555ceac0, 144 size
Tilengine: sequence created at 0x5555555cb050, 136 size
Tilengine: sequence 0x5555555ceac0 deleted
Tilengine: sequence 0x5555555cb050 deleted
Tilengine: bitmap 0x5555555cebb0 deleted
Tilengine: spriteset 0x5555555caf10 deleted
The palette is never deleted.
The function TLN_DeleteSpriteset
call to DeleteBaseObject (spriteset->bitmap)
but this does not delete the palette, as the function does TLN_DeleteBitmap
(need attention here for #50)
Fixed that I found another leak in the TLN_Deinit
function would be missing release engine
:
Something like that, I'm not sure:
void TLN_Deinit(void)
{
if (engine != NULL)
if (TLN_DeleteContext(engine))
free(engine);
}
Now, valgrind:
==4536==
==4536== HEAP SUMMARY:
==4536== in use at exit: 0 bytes in 0 blocks
==4536== total heap usage: 36 allocs, 36 frees, 547,947 bytes allocated
==4536==
==4536== All heap blocks were freed -- no leaks are possible
Regards.
from tilengine.
Hi
Today I found some more.
simplexml.c:
Line 332 in ea888ae
It should be replaced by:
destroySimpleXmlValueBuffer(parser->vbNextToken);
This fixes the memory leak.
New, Invalid read of size:
==3075== Invalid read of size 2
==3075== at 0x483CEE0: memcpy@GLIBC_2.2.5 (vg_replace_strmem.c:1034)
==3075== by 0x4858F0C: TLN_CreateTileset (Tileset.c:101)
==3075== by 0x4850BA1: TLN_LoadTileset (LoadTileset.c:230)
The problem is here:
Line 101 in ea888ae
I think the size of size_attributes
is incorrect since it is calculated after num++
Maybe it should be like this:
size_attributes = sizeof(TLN_TileAttributes) * numtiles;
numtiles++;
It would be equal to the previous calculation in:
Line 73 in ea888ae
This fixes the invalid read size.
There is another memory leak in CloneBaseObject
.
This function set dst->owner = false
Then somewhare:
if (ObjectOwner (spriteset))
This conditional does not allow the cloned object to be released, at least I am thinking so.
from tilengine.
Hi guys!
Thanks for your extensive reviews, I'll check all of them. The simplexml.c module is not mine so I don't know its internal logic, but all the others are mine.
from tilengine.
Tilengine uses a shallow object copy model. Only the initially created object owns references to their sibling objects. Cloned objects inherit the reference to the siblings from the original one, no siblings are cloned. That's why only objects created with CreateBaseObject()
have the owner
property set to true
so only them have the right to destroy their siblings. Cloned objects with CloneBaseObject()
don't have ownership of the siblings and cannot be destroyed recursively.
from tilengine.
The value of size_attribs
after numtiles++
is correct. This is done to include tiles with an id value of 0, that also count. In Tiled Editor the index of a tile is calculated substracting the tile index minus the id of the first valid tile in the tileset, that is 1. This difference between 0 and 1 based index requires incrementing by one the total number of tiles.
from tilengine.
TLN_DeleteContext()
is broken. It should be deleting the received context
reference, no the global engine
. This is a leftover from when it was only an instance. It also lacks a closing free(context)
at the end. I'll fix it.
from tilengine.
Memory leak in TLN_DeleteSpriteset()
:
The owned bitmap is being destroyed with DeleteBaseObject()
where it should be done with TLN_DeleteBitmap()
. DeleteBaseObject()
should only be used on the self object once their siblings have been properly destroyed using their appropiate TLN_DeleteXXX() destructors. It shouldn't be used to destroy siblings, as it cannot follow recursive siblings. Same happens to TLN_DeleteBitmap()
, it is improperly destroying its palette, but this hasn't noticeable effect because the palette doesn't contain further siblings. But must be fixed too.
from tilengine.
Related Issues (20)
- Sprite rotation capabilities HOT 1
- Memory corruption in "shooter" example HOT 3
- Crash when resuming animation HOT 1
- Unable to build on MacOS HOT 1
- non-initialized blinking borders when switching to fullscreen HOT 2
- V bindings HOT 1
- Tileset ordering in tmx file causing exception HOT 1
- Get tile returns incorrect tiles info type HOT 1
- Unable to build Tilengine HOT 1
- Actor.c from Samples dir, doesn't work HOT 1
- libretro port HOT 2
- Sprite not drawn after calling TLN_SetNextSprite HOT 2
- Tiled integration HOT 2
- real game source code HOT 1
- Getter for Layers, Tilemaps, Sprites, Tiles, ..., user data for callbacks, palette tile attribute, multiple tilesets per tilemap, and bug with TLN_SetTilemapTile()
- Pausing Specific Animations HOT 3
- Issues with custom overlay HOT 5
- Steps to reproduce the crash on exit in TLN_DeleteTileset
- Map layer with multiple .tsx files causes memory issues HOT 1
- TLN_GetTilemapTileset2 returns None/NULL HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tilengine.