Welcome to %s forums

BrainModular Users Forum

Login Register

Memory leaks in scripts

I need help on a Patch
Post Reply
woodslanding
Member
Posts: 1327
Contact:

Memory leaks in scripts

Unread post by woodslanding » 02 Dec 2024, 16:59

Well, I'm crazy excited because after 12(or more?) years of building my wkp in Usine, it is finally doing what I envisioned at the beginning. Thanks to Olivier et al for making this amazing software, thanks especially for Usine objects, and VST loadFromFileDirect which were both total game-changers for me!

So I have this marvellously debugged wkp doing exactly what I want, with one problem. When I transfer my wkp to my gig computer, it loads up all wrong, turns off a bunch of midi interfaces, and crashes the first time I try to load a file.

I understand now that this is because of memory leaks, and I'm trying to go through all my scripts looking for issues. The one thing that Olivier has mentioned is running off the end of an array. But I do not know what other practices might be a problem, and any further information on this would be welcome.

I will start off with a function that I imagine is an issue. I am paging through this list, but it looks like since I may remove an item partway through the process, I could try to address an element beyond the end of the list. Is this correct? I assume that the function does not stop as soon as it gets to the result line. If not, maybe this is fine. It still seems like bad form, so I am going to rewrite it:

Code: Select all

//// returns the data associated with a tag,
//// and removes the line containing the tag from the list
function CutLineForTag(TAG: string; list: tStringlist): string;
var line: string;
var i: integer;
begin
    for i := 0 to (list.count - 1) do
    begin
        //debug('checking line:' + intToStr(i) + ': ' + list.getStrings(i));
        line := list.getStrings(i);
        if stringsMatch(TAG, getTagForLine(line)) then
        begin
            result := getDataForLine(line);
            list.delete(i);
            debug('stripped ' + tag + ', value: ' + getDataForLine(line));
        end;
    end;
end;
I was hoping if anybody else has experienced these types of problems, they could post examples of their issues here... it is obviously a crucial part of script writing for Usine. As I find more, I will do so as well.

THANKS ALL!
=eric
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 07 Dec 2024, 20:51

well I only found a couple of errors that I know of. One issue I think might be that when a script is initialized, there may not be values at all the inputs. I traced N, and found times when I expected a value, but usine didn't have one yet. Not sure that's an actual problem, but I put in checks anyway. There were also several stringlists that didn't get destroyed, or were freed in a spot of code that wasn't always reached. I fixed those.

But I also think the install on my live computer got corrupted. I just pulled the whole directory over from the other computer and it is working fine now. Time to make sounds!

cheers,
-e
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests