sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/MemSamplerImpl.cpp
changeset 1 3ff3fecb12fe
equal deleted inserted replaced
0:f0f2b8682603 1:3ff3fecb12fe
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <piprofiler/ProfilerVersion.h>
       
    20 #include <piprofiler/ProfilerTraces.h>
       
    21 
       
    22 #include <kern_priv.h>
       
    23 #include <plat_priv.h>
       
    24 
       
    25 #include "MemSamplerImpl.h"
       
    26 
       
    27 // for testing precise stack utilization tracing...
       
    28 // crashes at the moment
       
    29 
       
    30 #include <nk_cpu.h>
       
    31 
       
    32 #if !defined(__NKERN_H__)
       
    33 #include <nkern.h>
       
    34 #endif 
       
    35 
       
    36 #define TAG(obj) (*(TUint32*)&(obj->iAsyncDeleteNext))
       
    37 #define PROFILER_CHUNK_MARK		((TUint32)0x00001000)
       
    38 #define PROFILER_MEM_THREAD_MARK	((TUint32)0x00000001)
       
    39 
       
    40 _LIT8(KMemVersion, "1.56");
       
    41 
       
    42 MemSamplerImpl::MemSamplerImpl() :
       
    43 	sampleDescriptor(&(this->sample[1]),0,256)
       
    44     {
       
    45 	LOGTEXT("MemSamplerImpl::MemSamplerImpl() - konstruktori");
       
    46 
       
    47 	iCount = 0;
       
    48 	iSampleThreads = true;
       
    49 	iTimeToSample = false;
       
    50 	
       
    51 	iTotalMemoryOk = false;
       
    52 	iTotalMemoryNameOk = false;
       
    53 	
       
    54 	iNewChunkCount = 0;
       
    55 	iChunkCount = 0;
       
    56 	iChunksProcessing = ENothingToProcess;
       
    57     iThreadsProcessing = ENothingToProcess;
       
    58 	
       
    59 	for(TInt i(0);i<PROFILER_MAX_THREAD_AMOUNT;i++)
       
    60 	    {
       
    61 		this->heapChunksToSample[i] = 0;
       
    62 		this->heapChunkNamesToReport[i] = 0;
       
    63 	    }
       
    64   
       
    65 
       
    66 	iNewThreadCount = 0;
       
    67 	iThreadCount = 0;
       
    68 	
       
    69 	for(TInt i=0;i<PROFILER_MAX_THREAD_AMOUNT;i++)
       
    70 	    {
       
    71 		this->threadsToSample[i] = 0;
       
    72 		this->threadNamesToReport[i] = 0;
       
    73 	    }
       
    74     }
       
    75 
       
    76 MemSamplerImpl::~MemSamplerImpl()
       
    77     {
       
    78 	
       
    79     }
       
    80 
       
    81 TInt MemSamplerImpl::CreateFirstSample()
       
    82     {
       
    83 	LOGTEXT("MemSamplerImpl::CreateFirstSample - entry");
       
    84 	
       
    85 	this->sampleDescriptor.Zero();
       
    86 	this->sampleDescriptor.Append(_L8("Bappea_V"));
       
    87 	this->sampleDescriptor.Append(KMemVersion);
       
    88 	this->sampleDescriptor.Append(_L8("_MEM"));
       
    89 	
       
    90 	sample[0] = this->sampleDescriptor.Size();
       
    91 
       
    92 	LOGTEXT("MemSamplerImpl::CreateFirstSample - exit");
       
    93 
       
    94 	return (TInt)(sample[0]+1);
       
    95     }
       
    96 
       
    97 TBool MemSamplerImpl::SampleNeeded()
       
    98     {
       
    99 
       
   100 	iCount++;
       
   101 	if ((iCount % iMemSamplingPeriod) == 0 || (iCount % iMemSamplingPeriodDiv2) == 0)
       
   102 	    {
       
   103 		LOGTEXT("MemSamplerImpl::SampleNeeded - true1");
       
   104 		iTimeToSample = true;
       
   105 		return true;
       
   106         }
       
   107 	else 
       
   108 	    {
       
   109 		return false;
       
   110         }
       
   111 
       
   112     }
       
   113 
       
   114 
       
   115 TInt MemSamplerImpl::SampleImpl()
       
   116     {
       
   117 
       
   118 	/*
       
   119 	 *
       
   120 	 *	EKA-2 implementation of MEM trace
       
   121 	 *
       
   122 	 */
       
   123     
       
   124     // check if either chunk or thread lists have unprocessed items
       
   125     if(this->iChunksProcessing == ENothingToProcess && !iSampleThreads)
       
   126         {
       
   127         if(!iTimeToSample)
       
   128             {
       
   129             return 0;
       
   130             }
       
   131         else
       
   132             {
       
   133             iTimeToSample = false;
       
   134             // gather first all chunks
       
   135             return GatherChunks();
       
   136             }
       
   137         }
       
   138     else if(!iSampleThreads)
       
   139         {
       
   140         // still something to go through in lists
       
   141         TInt length = this->ProcessChunks();
       
   142         
       
   143         if(length == 0) 
       
   144             {
       
   145             this->iChunksProcessing = ENothingToProcess;
       
   146             // switch to collect thread data
       
   147             iSampleThreads = true;
       
   148             }
       
   149         return length;
       
   150         }
       
   151     
       
   152     if(this->iThreadsProcessing == ENothingToProcess && iSampleThreads)
       
   153         {
       
   154         if(!iTimeToSample)
       
   155             {
       
   156             return 0;
       
   157             }
       
   158         else
       
   159             {
       
   160             iTimeToSample = false;
       
   161             // gather first all thread stacks
       
   162             return GatherThreads();
       
   163             }
       
   164         }
       
   165     
       
   166     else if(iSampleThreads)
       
   167         {
       
   168         // process now thread stack list
       
   169         TInt length = this->ProcessThreads();
       
   170 
       
   171         if(length == 0)
       
   172             {
       
   173             this->iThreadsProcessing = ENothingToProcess;
       
   174             // switch to collect chunk data
       
   175             iSampleThreads = false;
       
   176             }
       
   177         return length;
       
   178         }
       
   179 
       
   180     // should not reach this point...
       
   181     return 0;
       
   182     }
       
   183 
       
   184 inline TInt MemSamplerImpl::GatherChunks()
       
   185     {
       
   186     // encode a process binary
       
   187     name.Zero();
       
   188     DObjectCon& chunks = *Kern::Containers()[EChunk];
       
   189     
       
   190     this->iChunkCount = 0; 
       
   191     this->iNewChunkCount = 0;
       
   192     this->iTotalMemoryOk = false;
       
   193     TInt totalChunkCount = chunks.Count();
       
   194     
       
   195     for(TInt i=0;i<totalChunkCount;i++)
       
   196         {
       
   197         DChunk* c = (DChunk*)(chunks)[i];
       
   198 
       
   199         LOGSTRING3("Processing chunk %d, tag: 0x%x",i,TAG(c));
       
   200         if( (TAG(c) & 0x0000ffff) != PROFILER_CHUNK_MARK)
       
   201             {
       
   202             LOGSTRING2("Marking chunk %d",i);
       
   203             // this chunk has not been tagged yet
       
   204             name.Zero();
       
   205             c->TraceAppendName(name,false);
       
   206             const TUint8* ptr = name.Ptr();
       
   207             
       
   208             TAG(c) = (PROFILER_CHUNK_MARK);
       
   209             this->heapChunkNamesToReport[iNewChunkCount] = c;
       
   210             iNewChunkCount++;
       
   211             }
       
   212         else
       
   213             {
       
   214             LOGSTRING3("Chunk %d marked already - 0x%x",i,TAG(c));
       
   215             }
       
   216 
       
   217         // the chunk has been tagged, add heap chunks to the list
       
   218         this->heapChunksToSample[this->iChunkCount] = c;
       
   219         this->iChunkCount++;
       
   220         LOGSTRING2("Added chunk %d to Chunks",i);
       
   221         }
       
   222 
       
   223     if(this->iChunkCount > 0 || this->iNewChunkCount > 0)
       
   224         {
       
   225         this->iChunksProcessing = EStartingToProcess;
       
   226         
       
   227         // process the first sample
       
   228         TInt length = this->ProcessChunks();
       
   229         
       
   230         if(length == 0)
       
   231             {
       
   232             this->iChunksProcessing = ENothingToProcess;
       
   233             }
       
   234     
       
   235         return length;
       
   236         }
       
   237     else
       
   238         {
       
   239         // there were no threads, should not take place
       
   240         LOGTEXT("MemSamplerImpl::SampleImpl - Error, no threads"); 
       
   241         return 0;
       
   242         }
       
   243     }
       
   244 
       
   245 inline TInt MemSamplerImpl::GatherThreads()
       
   246     {
       
   247     // The thread memory consumption
       
   248     DObjectCon& threads = *Kern::Containers()[EThread];
       
   249 
       
   250     this->iThreadCount = 0; 
       
   251     this->iNewThreadCount = 0;
       
   252     this->iTotalMemoryOk = false;           
       
   253 
       
   254     TInt totalThreadCount = threads.Count();
       
   255 
       
   256     for(TInt i=0;i<totalThreadCount;i++)
       
   257         {
       
   258         DThread* t = (DThread*)(threads)[i];
       
   259 
       
   260         LOGSTRING3("Processing thread %d, tag: 0x%x",i,TAG(t));
       
   261 
       
   262         if( (TAG(t) & PROFILER_MEM_THREAD_MARK) == 0)
       
   263             {
       
   264             LOGSTRING2("Marking thread %d",i);
       
   265             // this thread's chunk has not been reported yet
       
   266             this->threadNamesToReport[iNewThreadCount] = t;
       
   267             iNewThreadCount++;
       
   268             // tag the thread
       
   269             TAG(t) |= PROFILER_MEM_THREAD_MARK;
       
   270             LOGSTRING2("New Thread %d",i);
       
   271             }
       
   272         else
       
   273             {
       
   274             LOGSTRING3("Thread %d marked already - 0x%x",i,TAG(t));
       
   275             }
       
   276 
       
   277         // the chunk has been tagged, add heap chunks to the list
       
   278         this->threadsToSample[this->iThreadCount] = t;
       
   279         this->iThreadCount++;
       
   280         LOGSTRING2("Added thread %d to threads to sample",i);
       
   281         }
       
   282     
       
   283     if(this->iThreadCount > 0 || this->iNewThreadCount > 0)
       
   284         {
       
   285         this->iThreadsProcessing = EStartingToProcess;
       
   286         
       
   287         // process the first sample
       
   288         TInt length = this->ProcessThreads();
       
   289         
       
   290         if(length == 0)
       
   291             {
       
   292             this->iThreadsProcessing = ENothingToProcess;
       
   293             }
       
   294     
       
   295         return length;
       
   296         }
       
   297     else
       
   298         {
       
   299         // there were no threads, should not take place
       
   300         LOGTEXT("MemSamplerImpl::SampleImpl - Error, no threads"); 
       
   301         return 0;
       
   302         }
       
   303     }
       
   304 
       
   305 inline TInt MemSamplerImpl::ProcessChunks()
       
   306     {
       
   307     if(iNewChunkCount > 0)
       
   308         {
       
   309             
       
   310         if(this->iChunksProcessing == EStartingToProcess)
       
   311             {
       
   312             // this is the first sample, encode a code for names
       
   313             this->iChunksProcessing = EProcessingNames;
       
   314             return EncodeNameCode();
       
   315             }
       
   316 
       
   317         if(iTotalMemoryNameOk == false)
       
   318             {
       
   319             return EncodeTotalMemoryName();
       
   320             }
       
   321         
       
   322         // there are new chunk names to report
       
   323         iNewChunkCount--;
       
   324         DChunk* c = this->heapChunkNamesToReport[iNewChunkCount];
       
   325         return EncodeChunkName(*c);
       
   326         
       
   327         }
       
   328     else if(iChunkCount > 0)
       
   329         {
       
   330         if(this->iChunksProcessing == EProcessingNames || this->iChunksProcessing == EStartingToProcess)
       
   331             {
       
   332             // this is the first data sample, encode a code for data
       
   333             this->iChunksProcessing = EProcessingData;
       
   334             return EncodeDataCode();
       
   335             }
       
   336         
       
   337         if(this->iTotalMemoryOk == false)
       
   338             {
       
   339             return EncodeTotalMemory();	
       
   340             }
       
   341 
       
   342         // there are no new chunks to report
       
   343         // thus generate the real report
       
   344         iChunkCount--;
       
   345         DChunk* c = this->heapChunksToSample[iChunkCount];
       
   346         return EncodeChunkData(*c);
       
   347         }
       
   348     else
       
   349         {
       
   350         // everything is processed
       
   351         return 0;
       
   352         }
       
   353     }
       
   354 
       
   355 inline TInt MemSamplerImpl::ProcessThreads()
       
   356     {
       
   357 
       
   358     if(iNewThreadCount > 0)
       
   359         {
       
   360         if(this->iThreadsProcessing == EStartingToProcess)
       
   361             {
       
   362             // this is the first sample, encode a code for names
       
   363             this->iThreadsProcessing = EProcessingNames;
       
   364             return EncodeNameCode();
       
   365             }
       
   366         
       
   367         if(iTotalMemoryNameOk == false)
       
   368             {
       
   369             return EncodeTotalMemoryName();
       
   370             }
       
   371 
       
   372         iNewThreadCount--;
       
   373         DThread* t = this->threadNamesToReport[iNewThreadCount];
       
   374         return EncodeChunkName(*t);
       
   375 
       
   376         
       
   377         }
       
   378     else if(iThreadCount > 0)
       
   379         {
       
   380         if(this->iThreadsProcessing == EProcessingNames || this->iThreadsProcessing == EStartingToProcess)
       
   381             {
       
   382             // this is the first data sample, encode a code for data
       
   383             this->iThreadsProcessing = EProcessingData;
       
   384             return EncodeDataCode();
       
   385             }
       
   386 
       
   387         if(this->iTotalMemoryOk == false)
       
   388             {
       
   389             return EncodeTotalMemory(); 
       
   390             }
       
   391 
       
   392         // there are no new threads to report
       
   393         // thus generate the real report
       
   394         iThreadCount--;
       
   395         DThread* t = this->threadsToSample[iThreadCount];
       
   396         return EncodeChunkData(*t);
       
   397         }
       
   398     else
       
   399         {   
       
   400         // everything is processed
       
   401         return 0;
       
   402         }
       
   403     }
       
   404 
       
   405 inline TInt MemSamplerImpl::EncodeNameCode()
       
   406     {
       
   407 	sample[0] = 1;
       
   408 	sample[1] = 0xaa;
       
   409 	return 2;
       
   410     }
       
   411 
       
   412 inline TInt MemSamplerImpl::EncodeDataCode()
       
   413     {
       
   414 	sample[0] = 1;
       
   415 	sample[1] = 0xdd;
       
   416 	return 2;
       
   417     }
       
   418 
       
   419 inline TInt MemSamplerImpl::EncodeTotalMemoryName()
       
   420     {
       
   421 	this->iTotalMemoryNameOk = true;
       
   422 	
       
   423 	TUint8* size = &sample[0];
       
   424 	*size = 0;
       
   425 		
       
   426 	// encode name
       
   427 	this->sampleDescriptor.Zero();
       
   428 	this->sampleDescriptor.Append(_L("TOTAL_MEMORY"));
       
   429 	*size += this->sampleDescriptor.Size();
       
   430 		
       
   431 	// add id here
       
   432 	TUint32 id = 0xbabbeaaa;
       
   433 	this->sampleDescriptor.Append((TUint8*)&(id),sizeof(TUint32));
       
   434 	*size += sizeof(TUint32);
       
   435 	
       
   436 	// the size is the descriptor length + the size field
       
   437 	return ((TInt)(*size))+1;	
       
   438     }
       
   439 
       
   440 inline TInt MemSamplerImpl::EncodeTotalMemory()
       
   441     {	
       
   442 	
       
   443 	TUint8* size = &sample[0];
       
   444 	*size = 0;
       
   445 
       
   446 	NKern::LockSystem();
       
   447 	TUint32 freeRam = Kern::FreeRamInBytes();
       
   448 	TUint32 totalRam = Kern::SuperPage().iTotalRamSize;
       
   449 	NKern::UnlockSystem();
       
   450 
       
   451 	this->sampleDescriptor.Zero();
       
   452 	
       
   453 	TUint32 id = 0xbabbeaaa;
       
   454 	TUint32 zero = 0;
       
   455 		
       
   456 	this->sampleDescriptor.Append((TUint8*)&(id),sizeof(TUint32));
       
   457 	*size += sizeof(TUint);
       
   458 	
       
   459 	this->sampleDescriptor.Append((TUint8*)&(totalRam),sizeof(TInt));
       
   460 	*size += sizeof(TInt);
       
   461 		
       
   462 	// append the cell amount allocated
       
   463 	this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt));
       
   464 	*size += sizeof(TInt);
       
   465 	
       
   466 	// append the chunk size
       
   467 	this->sampleDescriptor.Append((TUint8*)&(freeRam),sizeof(TUint));
       
   468 	*size += sizeof(TUint);
       
   469 		
       
   470 	// append the thread user stack size
       
   471 	this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt));
       
   472 	*size += sizeof(TInt);
       
   473 
       
   474 	this->iTotalMemoryOk = true;
       
   475 
       
   476 	return ((TInt)(*size))+1;
       
   477     }
       
   478 
       
   479 inline TInt MemSamplerImpl::EncodeChunkName(DChunk& c)
       
   480     {	
       
   481 	// the size of the following name is in the first byte
       
   482 	TUint8* size = &sample[0];
       
   483 	*size = 0;
       
   484 		
       
   485 	// encode chunk name
       
   486 	this->sampleDescriptor.Zero();
       
   487 	this->sampleDescriptor.Append(_L("C_"));
       
   488 	c.TraceAppendFullName(this->sampleDescriptor,false);
       
   489 	*size += this->sampleDescriptor.Size();
       
   490 		
       
   491 	// add chunk object address here
       
   492 	TUint32 chunkAddr = (TUint32)&c;
       
   493 	this->sampleDescriptor.Append((TUint8*)&(chunkAddr),sizeof(TUint32));
       
   494 	*size += sizeof(TUint32);
       
   495 
       
   496 	// the size is the descriptor length + the size field
       
   497 	LOGSTRING2("Non-Heap Chunk Name - %d",*size);
       
   498 	return ((TInt)(*size))+1;			
       
   499     }
       
   500 
       
   501 inline TInt MemSamplerImpl::EncodeChunkName(DThread& t)
       
   502     {		
       
   503 	// the size of the following name is in the first byte
       
   504 	TUint8* size = &sample[0];
       
   505 	*size = 0;
       
   506 	this->sampleDescriptor.Zero();
       
   507 	
       
   508 	this->sampleDescriptor.Append(_L("T_"));
       
   509 	t.TraceAppendFullName(this->sampleDescriptor,false);
       
   510 	*size += this->sampleDescriptor.Size();
       
   511 	
       
   512 	// copy the 4 bytes from the thread id field
       
   513 	this->sampleDescriptor.Append((TUint8*)&(t.iId),sizeof(TUint));
       
   514 	*size += sizeof(TUint);
       
   515 
       
   516 	// the size is the descriptor length + the size field
       
   517 	LOGSTRING2("Name - %d",*size);
       
   518 	return ((TInt)(*size))+1;
       
   519     }
       
   520 
       
   521 inline TInt MemSamplerImpl::EncodeChunkData(DChunk& c)
       
   522     {
       
   523 	// the size of the following name is in the first byte
       
   524 	TUint8* size = &sample[0];
       
   525 	*size = 0;
       
   526 	this->sampleDescriptor.Zero();
       
   527 	TInt zero(0);
       
   528 
       
   529 	TUint32 address = (TUint32)&c;
       
   530 		
       
   531 	this->sampleDescriptor.Append((TUint8*)&address,sizeof(TUint32));
       
   532 	*size += sizeof(TUint);
       
   533 	
       
   534 	// copy the total amount of memory allocated
       
   535 	this->sampleDescriptor.Append((TUint8*)&(c.iSize),sizeof(TInt));
       
   536 	*size += sizeof(TInt);
       
   537 		
       
   538 	// append the cell amount allocated
       
   539 	this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt));
       
   540 	*size += sizeof(TInt);
       
   541 	
       
   542 	// append the chunk size
       
   543 	this->sampleDescriptor.Append((TUint8*)&(c.iSize),sizeof(TUint));
       
   544 	*size += sizeof(TUint);
       
   545 		
       
   546 	// append the thread user stack size
       
   547 	this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt));
       
   548 	*size += sizeof(TInt);
       
   549 
       
   550 	LOGSTRING2("Data - %d",*size);
       
   551 	return ((TInt)(*size))+1;
       
   552 
       
   553     }
       
   554 
       
   555 inline TInt MemSamplerImpl::EncodeChunkData(DThread& t)
       
   556     {
       
   557 	LOGTEXT("MemSamplerImpl::EncodeChunkData - entry");
       
   558 	//LOGSTRING2("MemSamplerImpl::EncodeChunkData - processing thread 0x%x ",&t);
       
   559 		
       
   560 	// the size of the following name is in the first byte
       
   561 	TUint8* size = &sample[0];
       
   562 	*size = 0;
       
   563 	this->sampleDescriptor.Zero();
       
   564 
       
   565 	LOGTEXT("MemSamplerImpl::EncodeChunkData - cleared");
       
   566 
       
   567 	this->sampleDescriptor.Append((TUint8*)&(t.iId),sizeof(TUint));
       
   568 	*size += sizeof(TUint);
       
   569 		
       
   570 	// copy the total amount of memory allocated for user side stack
       
   571 	this->sampleDescriptor.Append((TUint8*)&(t.iUserStackSize),sizeof(TInt));
       
   572 	*size += sizeof(TInt);
       
   573 
       
   574 	TInt zero = 0;		
       
   575 	// append the cell amount allocated (zero, not in use here)
       
   576 	this->sampleDescriptor.Append((TUint8*)&zero,sizeof(TInt));
       
   577 	*size += sizeof(TInt);
       
   578 	
       
   579 	// append the chunk size (this is not a chunk)
       
   580 	this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TUint));
       
   581 	*size += sizeof(TUint);
       
   582 		
       
   583 	/*
       
   584 		// for testing precise stack utlilsation tracing...
       
   585 		// crashes at the moment
       
   586 
       
   587 		// append the current status of thread's stack utilisation
       
   588 		// this equals (stack pointer - stack base address)
       
   589 		TUint32* sp=(TUint32*)t.iNThread.iSavedSP;
       
   590 		TUint aUsrSP=sp[SP_R13U];
       
   591 		//TInt value = aUsrSP-t.iUserStackRunAddress;
       
   592 		this->sampleDescriptor.Append((TUint8*)&(aUsrSP),sizeof(TInt));
       
   593 		*size += sizeof(TInt);
       
   594 	*/
       
   595 	
       
   596 	// append user stack (max) size
       
   597 	this->sampleDescriptor.Append((TUint8*)&(t.iUserStackSize),sizeof(TInt));
       
   598 	*size += sizeof(TInt);
       
   599 
       
   600 	LOGSTRING2("Data -> %d",*size);
       
   601 	return ((TInt)(*size))+1;
       
   602     }
       
   603 
       
   604 void MemSamplerImpl::Reset()
       
   605     {
       
   606 	LOGTEXT("MemSamplerImpl::Reset");
       
   607 	iCount = 0; // sample threads 1 cycle after actual MEM sample time...
       
   608 	this->iSampleThreads = true;
       
   609     this->iTimeToSample = false;
       
   610     this->iChunkCount = 0;
       
   611 	this->iNewChunkCount = 0;
       
   612 
       
   613 	this->iTotalMemoryOk = false;
       
   614 	this->iTotalMemoryNameOk = false;
       
   615 
       
   616 	this->iChunksProcessing = ENothingToProcess;
       
   617     this->iThreadsProcessing = ENothingToProcess;
       
   618 	this->sampleDescriptor.Zero();
       
   619 
       
   620 	// clear all chunk tags
       
   621 	DObjectCon* chunks = Kern::Containers()[EChunk];
       
   622 	TInt totalChunkCount = chunks->Count();
       
   623 	for(TInt i=0;i<totalChunkCount;i++)
       
   624 	    {
       
   625 		DChunk* c = (DChunk*)(*chunks)[i];
       
   626 		TAG(c) = 0;
       
   627 	    }
       
   628 
       
   629 	LOGTEXT("MemSamplerImpl::Reset");
       
   630 	this->iThreadCount = 0;
       
   631 	this->iNewThreadCount = 0;
       
   632 	this->sampleDescriptor.Zero();
       
   633 
       
   634 	// clear all chunk tags
       
   635 	DObjectCon* threads = Kern::Containers()[EThread];
       
   636 	TInt totalThreadCount = threads->Count();
       
   637 	for(TInt i=0;i<totalThreadCount;i++)
       
   638 	    {
       
   639 		DThread* t = (DThread*)(*threads)[i];
       
   640 		TAG(t) = (TAG(t) & 0xfffffffe);
       
   641 	    }
       
   642     }
       
   643