views:

70

answers:

1

I have a method pointer like below:

typedef void (MMsnInternalCallBacks::* FuncPtr)();
FuncPtr iSoapActionComplete;

I call the method below through the pointer iSoapActionComplete like below:

(iCallbacks.*iSoapActionComplete)( );

While the function is being called a message "Memory Full. Try closing some applications" flashes on my Symbian S60 3rd Ed emulator.

Any idea why this could be happening.

+2  A: 

Does the function work if it's not being called through a method pointer but directly?

A likely cause for the message is that the function is leaving with KErrNoMemory i.e. -4 and the leave is caught by the application framework trap harness, resulting in an appropriate dialog.

Such a leave occurs for example when operator new(TLeave) fails to allocate memory or a zero argument is passed to User::LeaveIfNull(). Sometimes you can even see explicit User::Leave(KErrNoMemory) calls.

You can TRAP() the callback function call to catch leaves yourself. Better yet, you should fix the function itself to not to leave in normal sunny day scenarios.

(Also, by convention, leaving functions have the L suffix. Since you're using the i prefix for instance data, you are probably aware of the Symbian C++ naming conventions.)

laalto
laalto: Though hard to find the leave was caused by a failed memory allocation. The lesson I have learned is to TRAP every call that can leave. Thanks.
ardsrk
Don't TRAP every call that can leave. Let the leaves propagate to a high enough level where you can decide on an appropriate recovery strategy. The app framework's strategy of displaying a dialog and terminating (if leave occured during app construction) or continuing processing the next event (if leave occured during event processing i.e. eventually in active scheduler loop) is actually a quite good generic strategy.
laalto