Error memory Full....?

Login to reply to this topic.
Sat, 2008-05-03 08:30
Joined: 2008-01-26
Forum posts: 31

Hi.
I have a big file that it's size is 248 MB.The following code open this file :
void CPlayerAdapter::SetFileName( const TInt nFile1, const TInt nFile2, const TInt nFile3 )
{
User::LeaveIfError(fs.Connect());
User::LeaveIfError( SoundFile.Open(fs, FileName, EFileRead) );

if ( nFile1 != -1 )
{
SoundFile.Seek( ESeekStart, FilePos1 );
ptrSoundBuf1 = HBufC8::NewL( FileLen1 );
ptr1 = new (ELeave)TPtr8( ptrSoundBuf1->Des() );
SoundFile.Read(*ptr1, FileLen1 );
iState=ENotReady;
imda1 = CMdaAudioPlayerUtility::NewDesPlayerL( *ptr1, *this );
iMdaAudioPlayerUtility = imda1;

}
if ( nFile2 != -1 )
{
SoundFile.Seek( ESeekStart, FilePos2 );
ptrSoundBuf2 = HBufC8::NewL( FileLen2 );
ptr2 = new (ELeave) TPtr8( ptrSoundBuf2->Des() );
SoundFile.Read( *ptr2, FileLen2 );
iState=ENotReady;
imda2 = CMdaAudioPlayerUtility::NewDesPlayerL( *ptr2, *this );

}
if ( nFile3 != -1 )
{
SoundFile.Seek( ESeekStart, FilePos3 );
ptrSoundBuf3 = HBufC8::NewL( FileLen3 );
ptr3 = new (ELeave) TPtr8( ptrSoundBuf3->Des() );
SoundFile.Read( *ptr3, FileLen3 );
iState=ENotReady;
imda3 = CMdaAudioPlayerUtility::NewDesPlayerL( *ptr3, *this );
}

SoundFile.Close();
fs.Close();
}

CPlayerAdapter* CPlayerAdapter::NewL(
const TInt nFile1, const TInt nFile2, const TInt nFile3
MInternetRadioAdapterObserver& aObserver )
{

CPlayerAdapter* self = NewLC( nFile1 ,nFile2, nFile3, aObserver);
CleanupStack::Pop(self);
return self;
}

// -----------------------------------------------------------------------------
// CPlayerAdapter::NewL
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CPlayerAdapter* CPlayerAdapter::NewLC( const TInt nFile1, const TInt nFile2, const TInt nFile3,
MInternetRadioAdapterObserver& aObserver )
{
CPlayerAdapter* self = new (ELeave) CPlayerAdapter(aObserver);
CleanupStack::PushL(self);
self->ConstructL( nFile1 ,nFile2, nFile3 );
return self;
}

void CPlayerAdapter::ConstructL( const TInt nFile1, const TInt nFile2, const TInt nFile3 )
{
iMdaAudioPlayerUtility = NULL;
SetFileName( nFile1 ,nFile2, nFile3 );
nCurFileNo = 0;
}

I delete ptrSoundBuf and ptr, and make NULL them in deConstructor.
In another Class i have:
iPlayerAdapter = CPlayerAdapter::NewL( nFile1, nFile2, nFile3, *this);
and delete iPlayerAdapter in deconstructor.But after several times,that i go in this class, Error
memory full.Close some application and try again,is occured.
I anybody help me?
Thanks alot.


Sun, 2008-05-04 18:10
Joined: 2003-12-05
Forum posts: 586
Re: Error memory Full....?

Difficult to make sense of your code, not knowing which variables are local, which member variables, which global and what values they have. For example:

ptrSoundBuf1 = HBufC8::NewL( FileLen1 );

How much memory are you trying to allocate here? You must know that most newest phones have at most tens of megabytes of free RAM to allocate? Optimistically, when no other apps are running. In older phones you have only 1-15 megabytes when no other apps are running.

Mon, 2008-05-05 22:44
Joined: 2007-09-23
Forum posts: 132
Re: Error memory Full....?

A TPtr and a TPtrC is not a C/C++ pointer - you should not allocate these on the heap.

And what about deleting all those other objects you create?

  • Login to reply to this topic.