DirectDance
08-29-2007, 12:45 PM
Hi,
I have a problem re free memory on my PPC, when performing more complex poom commands.
This example is looking for the first contact in the adress book (starting with an a), loading its OID, load the contact itself using the OID and get some properties.
For testing, I have loaded the same contact 10 times (does not make sense in real life, but it is the same if using findnext in a loop).
Here is the piece of code:
#include "swapi.ppl"
//This Sample code will find the first contact, beginning with an A
//and loads the contact and it´s propertys 10 times for testing
func WinMain
struct(lpMem$, MEMORYSTATUS);
GlobalMemoryStatus (&lpMem$);
membefore$ = (lpMem.dwAvailPhys$/1024);
showmessage("Free Memory before executing " % membefore$);
poom$ = CreateCOMObject("PocketOutlook.Application");
result$ = Invoke(poom$, "logon");
folder$ = Invoke(poom$, "GetDefaultFolder", 10);
items$ = GetProperty(folder$, "items");
findcontact$ = invoke(items$, "find", "[LastName] >= \"A\"");
votest$ = getproperty(findcontact$, "oid");
for(u$, 1, 10, 1)
//Einen Datensatz direkt über die OID laden (wenn bekannt)
loadmycontact$ = invoke(poom$, "GetItemFromOid", votest$);
name1$ = getproperty(loadmycontact$, "firstname");
name2$ = getproperty(loadmycontact$, "lastname");
//showmessage(name1$ % ", " % name2$);
end;
Invoke(poom$, "logoff");
invoke(poom$, "Release");
freecomobject(poom$);
GlobalMemoryStatus (&lpMem$);
memafter$ = (lpMem.dwAvailPhys$/1024);
showmessage("Free memory after loop " % int(memafter$));
exit;
end;
What will happen:
Until the for/next command, all is fine, because those commands are only called once.
The loop itself will create 10 com objects to "loadmycontact", I think. The result is, that the memory will go down.
If changing the for/next loop to:
for(u$, 1, 10, 1)
//Einen Datensatz direkt über die OID laden (wenn bekannt)
loadmycontact$ = invoke(poom$, "GetItemFromOid", votest$);
name1$ = getproperty(loadmycontact$, "firstname");
name2$ = getproperty(loadmycontact$, "lastname");
//showmessage(name1$ % ", " % name2$);
invoke(loadmycontact$, "Release"); //INSERTED
freecomobject(loadmycontact$); //INSERTED
end;
than, the created com object should be destroyed in the loop after it was used. Well, in smaller apps like the listed above, it is working very often. But if adding only a few commands to the above listed example, the invoke in the second loop (if u$ >= 2) will crash showing adress misalligned. It seems, that the freecomobject has changed the function "GetItemFromOid", so its parent. Other poom commands down from the poom$ object are still working.
The problem is, if somebody do have 200 contacts on the PPC, by loading them in a loop and displaying them somewhere, the PPC will go out of memory before the result is visible. Adding the freecomobject is resulting in a crash on my PPC.
Anybody with other experiences ??? I have tried a few days to find a solution but have not found one ...
Many thanks,
DirectDance[br]1188391495_11_FT0_memloss.zip
I have a problem re free memory on my PPC, when performing more complex poom commands.
This example is looking for the first contact in the adress book (starting with an a), loading its OID, load the contact itself using the OID and get some properties.
For testing, I have loaded the same contact 10 times (does not make sense in real life, but it is the same if using findnext in a loop).
Here is the piece of code:
#include "swapi.ppl"
//This Sample code will find the first contact, beginning with an A
//and loads the contact and it´s propertys 10 times for testing
func WinMain
struct(lpMem$, MEMORYSTATUS);
GlobalMemoryStatus (&lpMem$);
membefore$ = (lpMem.dwAvailPhys$/1024);
showmessage("Free Memory before executing " % membefore$);
poom$ = CreateCOMObject("PocketOutlook.Application");
result$ = Invoke(poom$, "logon");
folder$ = Invoke(poom$, "GetDefaultFolder", 10);
items$ = GetProperty(folder$, "items");
findcontact$ = invoke(items$, "find", "[LastName] >= \"A\"");
votest$ = getproperty(findcontact$, "oid");
for(u$, 1, 10, 1)
//Einen Datensatz direkt über die OID laden (wenn bekannt)
loadmycontact$ = invoke(poom$, "GetItemFromOid", votest$);
name1$ = getproperty(loadmycontact$, "firstname");
name2$ = getproperty(loadmycontact$, "lastname");
//showmessage(name1$ % ", " % name2$);
end;
Invoke(poom$, "logoff");
invoke(poom$, "Release");
freecomobject(poom$);
GlobalMemoryStatus (&lpMem$);
memafter$ = (lpMem.dwAvailPhys$/1024);
showmessage("Free memory after loop " % int(memafter$));
exit;
end;
What will happen:
Until the for/next command, all is fine, because those commands are only called once.
The loop itself will create 10 com objects to "loadmycontact", I think. The result is, that the memory will go down.
If changing the for/next loop to:
for(u$, 1, 10, 1)
//Einen Datensatz direkt über die OID laden (wenn bekannt)
loadmycontact$ = invoke(poom$, "GetItemFromOid", votest$);
name1$ = getproperty(loadmycontact$, "firstname");
name2$ = getproperty(loadmycontact$, "lastname");
//showmessage(name1$ % ", " % name2$);
invoke(loadmycontact$, "Release"); //INSERTED
freecomobject(loadmycontact$); //INSERTED
end;
than, the created com object should be destroyed in the loop after it was used. Well, in smaller apps like the listed above, it is working very often. But if adding only a few commands to the above listed example, the invoke in the second loop (if u$ >= 2) will crash showing adress misalligned. It seems, that the freecomobject has changed the function "GetItemFromOid", so its parent. Other poom commands down from the poom$ object are still working.
The problem is, if somebody do have 200 contacts on the PPC, by loading them in a loop and displaying them somewhere, the PPC will go out of memory before the result is visible. Adding the freecomobject is resulting in a crash on my PPC.
Anybody with other experiences ??? I have tried a few days to find a solution but have not found one ...
Many thanks,
DirectDance[br]1188391495_11_FT0_memloss.zip