Creating instances with _runtime.CreateInstance(obj,layer,x,y) causes memory leaks

0 favourites
  • 4 posts
From the Asset Store
Test and challenge your memory in this amazing Christmas themed memory game!
  • Hello,

    I have a plugin which continuously spawns object instances using the _runtime.CreateInstance function from the SDK Documentation.

    Apart from the fact that Construct does not trigger the On Created event of the said object there appears to be another problem related to memory leaks.

    Whenever I create a new instance the memory usage of the preview tab goes up by 2-3 MB everytime which in the end causes the tab to crash with the "Not enough memory to run this page" error.

    Here is the instance creation code I use:

    	CreateInstance(enemy, x, y)
    	{
    		var obj = this._runtime.GetObjectClassByName(enemy.ShortName);
    		var inst = this._runtime.CreateInstance(obj, this._spawnLayer, x, y);
    		inst._instVarValues[0] = enemy.Health;
    		inst._instVarValues[1] = enemy.MaxHealth;
    		inst._instVarValues[2] = enemy.MaxHealth;
    		inst._instVarValues[3] = enemy.MovementSpeed;
    		inst._instVarValues[24] = enemy.BulletResist;
    		inst._instVarValues[25] = enemy.CorrosiveResist;
    		inst._instVarValues[26] = enemy.SlashResist;
    		inst._instVarValues[35] = enemy.Bounty;
    	}
    

    There might be something faulty with how I handle the runtime methods so any help regarding this issue will be appreciated.

    Also, here is the entire Plugin Addon I use if that might be of any help.

    Thank you!

  • You're using unsupported SDK features so we will not offer support. See the warning in the manual:

  • Hey Ashley,

    I am sorry but it seems I was wrong about the issue.

    I think that the root of the problem is the pathfinder behaviour which has as obstacle a tilemap with the solid behaviour.

    Here is how it looks: (the gray row in the taskbar is the preview tab)

    Subscribe to Construct videos now

    &

    Capx file

    The idea is that whenever Find Path is invoked the memory usage spikes a few mb's depending on the path length.

    It is a bad practice to use pathfinder and tilemap like this or is there another problem?

    Later Edit: I have managed to reproduce this issue on the pathfinding examples so I guess the tilemap is not the problem (?)

    From what I've tested this does happen on Mozilla and IEdge aswell.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It's probably just garbage collection, and the GC not running yet because the system isn't under memory pressure. Anyway that appears unrelated to the original post and should be filed as a bug report following all the guidelines if it is to be investigated.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)