Problems with FPC_LoadOCXCodeFromMemory and FPC_UnloadCode

DLL Edition of the F-IN-BOX
RobertG
Posts: 10
Joined: Mon Apr 28, 2008 2:45 pm

Problems with FPC_LoadOCXCodeFromMemory and FPC_UnloadCode

Postby RobertG » Fri Jan 16, 2009 11:10 am

We are playing a lot of flash movies => several days.
and we have noticed that unloading of DLL that seem to be related to
FPC_LoadOCXCodeFromMemory

Eafter each flash movie we are deleting/unloading entire Flash system. even ocx the file in case a user interupts and all resources are being needed for other things in the machine.

We have noticed for the f_in_box 3.2.1 dll edition.
That each time we load the ocx file into the memory and after one movie have been played doing an unload of the ret = FPC_UnloadCode(m_hFPC); we seem to get a handle leakage. which seam to affect the window resources eventually.

data declared as
LPVOID data;
DWORD sz;

We are doing an own file load to data and alocating memory and retreiving the file size.

m_hFPC = FPC_LoadOCXCodeFromMemory(data, sz);

After the movie we are destroying everything and unload the OCX aswell.
Problem is that after 2-4 days depends on the movies we are out of windos resources, we are using a memory validator that has captured this leakage of handlers?? have we missed something here when dealing with the OCX functions?

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Jan 16, 2009 3:27 pm

Thank you for your question.

Could you please give me more information.

Is it possible to reproduce the problem? I've tried a quick test and it works well:

Code: Select all

while(true)
{
FPC_LoadOCXCodeFromMemory
...
CreateWindowEx
...
FPC_LoadMovie
...
FPC_UnloadCode
}


I need your help to resolve this issue.

Thank you in advance.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

RobertG
Posts: 10
Joined: Mon Apr 28, 2008 2:45 pm

Postby RobertG » Fri Jan 16, 2009 4:38 pm

It would be nice to know what the reason really is?? we can se that several DLL are unloaded and loaded between the movies. and it always looses a handle ? MemoryValidator doesn't detect it as a leakage but we can clearly see that it is growning between the Flash Movies/Clips and Memory validator points out the allocation of Handle is done in the FPC_LoadOCXCodeFromMemory / FPC_LoadRegisteredOCX() (I have tried both with same problem), after couple of days our Windows gets out of resources (HANDLES)... connected with DLL

Main Architecture of flash player.

Well we have a cycle for each movie where we did the following

but in our case it also includes a creation of a new thread.
This is done because if we would like to play multiple movies on different screens and timeing of the FPS to be more accurate independent from main app, etc.

while(true)
{
Creating new thread from main app

example :
if (_flashThread == 0)
_flashThread = reinterpret_cast<HANDLE>(::_beginthreadex( NULL, NULL, &ThreadFunc, _flashThreadData, 0, (unsigned *)&_threadID));

check / frame when movie finnished

trigger a close for thread.
DWORD dwRet = WaitForSingleObject( _flashThread, INFINITE ); // Kill thread from thread proc()

(NOTE THREAD WILL DO ALL THE CLEAN UP FOR FLASH, REG Window and Flash Window) flash isn't handled from the mian thread!

}



ThreadFunc()
{
FPC_LoadOCXCodeFromMemory
...
CreateWindowEx
...
FPC_LoadMovie
...

// Loop ThreadProc handling Win pumps etc.

PLay Movie .

// When a teardown is detected

Cleanup => Destroy Flash Window & Destroy Reg Window
FPC_UnloadCode

Exit thread...
}




TEMPORARY SOLUTION SO FAR:
I have a temporary solution that is to statically load OCX once and reuse during app lifetime. (Reusing same OCX for all clips).

Seems to work well, but I am unsure how it will cope with multiple movies though. I haven't tested it yet.

However by loading OCX statically it seems to be able to survive when windows being out of resources example:
I have started 26 Explorers ,Windows outlook Excell etc.. and got a message box that Windows is out of resources, And the flash player is still doing well where previously it would give mee NULL handles and failed bitmap captures or failed to start/load movies etc.

We can now also se the with static load of ocx DLL Handle Leakage have stopped.


Huh.. hope it helps you a little bit.
Br Rob

RobertG
Posts: 10
Joined: Mon Apr 28, 2008 2:45 pm

Postby RobertG » Fri Jan 16, 2009 4:54 pm

Hmm after further studies I noticed and that the when statically loading the flash.ocx component it reserves a lot of memory ~300 Mb after running a couple of hours and never removes the mem maybee cacheing I don't know. but that casues problem for our environment because our memory is limited and we really need to remove the OCX when it is not being used. :(

//Br Rob.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Mon Jan 19, 2009 4:18 pm

Could you please make the following test. Before calling FPC_UnloadCode, call FPC_CanUnloadNow:

BOOL WINAPI FPC_CanUnloadNow(HFPC hFPC);

What does it return?

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

RobertG
Posts: 10
Joined: Mon Apr 28, 2008 2:45 pm

Postby RobertG » Tue Jan 20, 2009 1:45 pm

I have now upgraded our app with the latest f_in_box.dll
FPC_CanUnloadNow Works perfectly. .

If I don't load a movie, everthing works fine Loading the OCX and unloading the OCX.
our threading model works fine, (we needed to se that we didn't have any external disturbance in the system by removing chunks of Flash inits.)

But.. Once I load the movie (FPC_PutMovie or FPCPutMovieFromMemory) we start to have handle leakages

Indicators points out handles for either urlmon.dll Mpr.dll difficult to see
need to debug more.

I even do the FPC_PutMovie(m_hwndFlashCtrl, ""); as an unload precaution but no help there either?

Br Rob.

RobertG
Posts: 10
Joined: Mon Apr 28, 2008 2:45 pm

Postby RobertG » Thu Jan 22, 2009 5:31 pm

Well problem still persists.

1. Solution 1
When opening and closing windows/OCX/movie we get out of windows resources after 48 hourse. Could be a Window issue here though.

2. Solution 2
If loading OCX Statically and reuse reg window sems to get memory growing > 1 Gb after 48 hours. Eventhogh I do the
load empty movie as an unload precation...
(Seems to be a leakage in the area of FPCPutMovieUsingStream)
or FPC_IStream_SetSize ??? Can't really tell here, but these names are shown often in memory validator as a possible leakage.

Br Rob.

RobertG
Posts: 10
Joined: Mon Apr 28, 2008 2:45 pm

Postby RobertG » Fri Jan 23, 2009 4:48 pm

Noticed when testing with different flash.ocx version of different problems
for instance flash10a.ocx cannot load ocx files to often without resulting in a crash... that doesn't happen with flash9x don't remember versions :(

is there a specific flash ocx that has proven to be better in stability then others? in that case which version?

Br Rob.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Tue Jan 27, 2009 12:33 pm

Could you please check new update?

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html


Return to “DLL Edition”

Who is online

Users browsing this forum: No registered users and 12 guests