PDA

View Full Version : Bug in run / call function


DirectDance
07-16-2007, 12:29 PM
Hi,

there seems to be a bug in the run / call functions.

Calling a code the first time is working well.

Without closing the main program (in my case, my menu program wich is for calling the sub programs), so, the PPL session is still active, when calling the same sub code again and again, PPL crashes after e.g. the fourth time.

The taskbar (on the desktop - pc) will loose the program.

I copied the debuglog.txt. What is interesting, the memory will be less and less by each call. Of course, I killed the applications after ending.

Here is the debuglog.txt. After the last entry, PPL crashed:

BPD_MAINMENU.PPL is my main program, wich is only started once.
BPD_EDIT.PPL is my Database Design program wich is called from BPD_MAINMENU.PPL
BPDATAPLUS.PPL is the application, wich is for entering data into the project, wich was designed using BPD_EDIT.PPL. BPDATAPLUS.PPL is also called from the main application BPD_MAINMENU.PPL

16.07.2007 01:56:33 : Generated by the PPL interpreter v.1.25 Pro
16.07.2007 01:56:33 : Root C:\Programme\PPL\RUNTIME\
16.07.2007 01:56:33 : Available memory 47,177,728 bytes
16.07.2007 01:56:33 : BPD_MAINMENU.PPL started
16.07.2007 01:56:57 : Generated by the PPL interpreter v.1.25 Pro
16.07.2007 01:56:57 : Root C:\Programme\PPL\RUNTIME\
16.07.2007 01:56:58 : Available memory 42,082,304 bytes
16.07.2007 01:56:58 : BPD_EDIT.PPL started
16.07.2007 01:57:14 : Generated by the PPL interpreter v.1.25 Pro
16.07.2007 01:57:14 : Root C:\Programme\PPL\RUNTIME\
16.07.2007 01:57:14 : BPD_EDIT.PPL ended (15,781 ms)
16.07.2007 01:57:14 : Available memory 44,429,312 bytes
16.07.2007 01:57:14 : Available memory 38,936,576 bytes
16.07.2007 01:57:14 : BPDATAPLUS.PPL started
16.07.2007 01:57:46 : BPDATAPLUS.PPL ended (31,390 ms)
16.07.2007 01:57:46 : Available memory 45,580,288 bytes
16.07.2007 01:59:16 : Generated by the PPL interpreter v.1.25 Pro
16.07.2007 01:59:16 : Root C:\Programme\PPL\RUNTIME\
16.07.2007 01:59:17 : Available memory 42,254,336 bytes
16.07.2007 01:59:17 : BPD_EDIT.PPL started
16.07.2007 01:59:54 : Generated by the PPL interpreter v.1.25 Pro
16.07.2007 01:59:54 : Root C:\Programme\PPL\RUNTIME\
16.07.2007 01:59:54 : BPD_EDIT.PPL ended (37,484 ms)
16.07.2007 01:59:54 : Available memory 42,151,936 bytes
16.07.2007 01:59:55 : Available memory 36,900,864 bytes
16.07.2007 01:59:55 : BPDATAPLUS.PPL started
16.07.2007 02:00:51 : BPDATAPLUS.PPL ended (55,766 ms)
16.07.2007 02:00:51 : Available memory 44,118,016 bytes
16.07.2007 02:01:15 : Generated by the PPL interpreter v.1.25 Pro
16.07.2007 02:01:15 : Root C:\Programme\PPL\RUNTIME\
16.07.2007 02:01:15 : Available memory 39,010,304 bytes
16.07.2007 02:01:15 : BPD_EDIT.PPL started
16.07.2007 02:01:49 : Generated by the PPL interpreter v.1.25 Pro
16.07.2007 02:01:49 : Root C:\Programme\PPL\RUNTIME\
16.07.2007 02:01:49 : BPD_EDIT.PPL ended (34,391 ms)
16.07.2007 02:01:49 : Available memory 40,374,272 bytes
16.07.2007 02:01:50 : Available memory 35,016,704 bytes
16.07.2007 02:01:50 : BPDATAPLUS.PPL started

Cheers,
Directdance

kornalius
07-16-2007, 01:29 PM
Without a little piece of code it will be hard for me to help you. Show us the code you are using to run the code. t looks like you are not freeing up the memory used by the called application.

DirectDance
07-16-2007, 01:56 PM
Here is the code wich will start the sub code.

Those are the EDIT PROJECT Button and the RUN PROJECT Button. I hope this will help ...


//This is the Run Project Knob

func BITMAP105_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms

//Check if Edit Project is in Memory. If yes, kill it to maximize memory

app$ = FindApp("bpd_edit.ppl");
if(app$ == null)
//nothing
else
KillApp(app$);
end;


//Now check, if RUN PROJECT is allready loaded, if yes, just call it, if no, compile it

app$ = FindApp("bpdataplus.ppl");

if (app$ == null)
MyLib$ = Run(AppPath$ + "bpdataplus");
Call(MyLib$, "runproject");
else
Call(MyLib$, "runproject");
end;

end;
return (true);

end;


//This is the Edit Project Knob
func BITMAP102_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms

//Check if RUN Project is in Memory. If yes, kill it to maximize memory

app$ = FindApp("bpdataplus.ppl");
if(app$ == null)
//nothing
else
KillApp(app$);
end;


//Now check, if EDIT PROJECT is allready loaded, if yes, just call it, if no, compile it

app$ = FindApp("bpd_edit.ppl");
if(app$ == null)
MyLib$ = Run(AppPath$ + "bpd_edit");
Call(MyLib$, "mainchoose", onlyfilename%);
else
Call(MyLib$, "mainchoose", onlyfilename%);
end;

end;
return (true);

end;

kornalius
07-16-2007, 03:02 PM
Are you sure FindApp() ever finds the application? I am almost sure it returns NULL at all time.

I will take a look at the Call function to see if there is any memory leak.

DirectDance
07-16-2007, 03:19 PM
The find() in PPL 1.25 is working very fine.

If the e.g. Run Project is loaded, findapp finds it and only the call will be executed. Btw., forgotten to tell. this is working without any failures.

The problem only appears when the code was loaded before, then killed and after that compiled again and called.

I am using the findapp because, if a user has allready loaded the RUN PROJECT program and wants to restart it, it is not necessary to recompile it. Only to kill it, when another program should be loaded.

I am sure, the findapp is working, because for testing I added showmessages commands to check the status of the variables. And it never failed.

kornalius
07-17-2007, 01:01 AM
Ok great, so then it could either be the FreeApp() that has memory leaks or the Call() function. I will do some testings tomorrow and get back to you.

kornalius
07-17-2007, 11:17 AM
Hi DirectDance, in version I get no memory leaks in Call() neither FreeApp().

Can you send me a concrete SMALL example where you can get it to crash?

kornalius
07-17-2007, 11:19 AM
Here is a code I used for testing and it doesn't crash, there might be something else going on with your code:

// My library testlib.ppl

forcelink func testfunc (a$, b$)
return (a$ + b$);
end;

func WinMain
return(true);
end;

// My calling code CallLib.ppl

proc main
a$ = Run(AppPath$ + "testlib");
if (a$)
For (i$, 1, 1350)
Call(a$, "testfunc", 10, 20);
end;
KillApp(a$);
end;
end;

DirectDance
07-18-2007, 07:11 AM
Hmmm, curious ...

as mentioned before, the call is not the problem on my side. Once compiled using run, I can call my sub code as often as I want. But when killed and recompiled, then the call sometimes crashes.

But the reason must be a code / function in my called application. For testing, I called another form in my called application. That one only displayes a form and nothing more. It is not crashing.

I thought, once an application is killed, all variables are killed, too. I will eliminate line by line to have a look, what the reason for this is ...

Many thanks,
DirectDance

kornalius
07-18-2007, 11:02 AM
Ha I see. I will try to re-run the code everytime in my test loop and I will get back to you.

All variables (global and local) to the program will be freed when the application is killed, correct.

kornalius
07-18-2007, 01:18 PM
Hi,

I have found an issue with the optimization caching that I am using. I will find a work around, that should fix this issue.

DirectDance
07-18-2007, 02:17 PM
That are good news Kornalius!

So, I will stop searching in my code for the moment.

What was interesting, for my tests I used a button in my program wich calls the sub program:

a$ = Run(AppPath$ + "bpdataplus");
app$ = FindApp("bpdataplus.ppc");
showmessage(a$ % " " % app$);
Call(a$, "runproject");
showmessage("I am back before killing the app");
KillApp(a$);
showmessage("killed it");

I thought, in case of failure, the run would give a wrong pointer, but it wont. In every case, even before crashing, a$ and app$ were the same. So, the run command should be the bad one ...

Btw., in the new version, is the starting process of an exe file still optimized (no compilation a second time)?

And if so, now that I have seperated my programs to parts, my main prog has still a size of about 685 kb (the .ppc file). Before it was 1.191 kb (also, the .ppc file). Is that great advantage of reducing the starting time also affecting my one if I use run and call ?

Thanks,
DirectDance