YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

SQRat binging leaks with NO_GARBAGE_COLLECTOR
MicioMax
#1 Posted : Tuesday, November 7, 2017 10:01:27 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/16/2017(UTC)
Posts: 9

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

setting NO_GARBAGE_COLLECTOR flag I found that SQRat bingings leak memory.
I traced all malloc's and frees (from VM creation up to VM closing), both with and without GC; in latter case this code

Code:

SQInteger registerStreamLib(HSQUIRRELVM v)
{
    Class<SqStream, NoConstructor<SqStream>> sqStream(v, "Stream");
    return 0;
}


(yep, even without a call to Bind()...) leaks 2342 bytes in my build.
The weird stuff is that building with GC and setting a debug point into garbage collect code (in SQSharedState::~SQSharedState())
shows nothing... all data is freed BEFORE the GC which does absolutely nothing, as the _gc_chain is empty.

What can be the cause ? I'm trying to optimize Squirrel to run on an embedded PIC32 system with smallest RAM usage, and GC is one
of the stuffs I'm trying to remove.
Ah, in this test I disabled ALL other optimizations, the shown leak is on a vanilla 64 bit Squirrel 3.1 build with only GC disabled.
fagiano
#2 Posted : Sunday, November 12, 2017 5:29:26 AM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 1,059

Thanks: 0 times
Was thanked: 79 time(s) in 61 post(s)
If that is that a single 2342 bytes block, you could put an assert in the allocator and see who is the offending allocation(or at least what type of object). To generate a memory leak with squirrel you must have a reference cycle, I never seen a leak elsewhere. However you say that _gc_chain is empty, so I'm puzzled.

Alberto
Follow me on Twitter @squirrellang
1 user thanked fagiano for this useful post.
MicioMax on 11/13/2017(UTC)
MicioMax
#3 Posted : Monday, November 13, 2017 10:31:20 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/16/2017(UTC)
Posts: 9

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
I found leak's cause and patched it on my tree, at least for this case. I noticed that sqrat relies on GC to free ram on VM closing, which is bad if GC is disabled and the VM is closed/reopened on each run as in my case.
I still don't understand why the GC chain was empty, but maybe I looked in wrong place.

Anyways sqrat uses too much of RAM for my purposes, so I'm writing an alternative template binding code which uses less resources.

BTW, I modified squirrel too (with some #defines...) to lower its RAM usage. Work still in progress, but up to now my free ram raised
from 40-50 K to more than 90K (of 128 total available) and I'm almost happy with it.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.068 seconds.