src/app/netcache/nc_memory.cpp File Reference

#include <ncbi_pch.hpp>
#include <db/sqlite/sqlitewrapp.hpp>
#include "nc_memory.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>

Include dependency graph for nc_memory.cpp:

Go to the source code of this file.

Functions

 DEFINE_CLASS_STATIC_FAST_MUTEX (CNCMMCentral::sm_CentralLock)
static unsigned int s_GetCntPerGrade (unsigned int total, unsigned int grades)
 Get number of blocks (or something else) per each emptiness grade when given total number of blocks and number of grades.
static unsigned int s_GetGradeValue (unsigned int cur_cnt, unsigned int cnt_per_grade)
 Get emptiness grade value when given current number of blocks (or something else) and number of blocks per each grade.
static int s_SQLITE_PCache_Init (void *)
 Initialize database cache.
static void s_SQLITE_PCache_Shutdown (void *)
 Deinitialize database cache.
static sqlite3_pcache * s_SQLITE_PCache_Create (int szPage, int bPurgeable)
 Create new cache instance.
static void s_SQLITE_PCache_SetSize (sqlite3_pcache *pcache, int nCachesize)
 Set size of database cache (number of pages).
static int s_SQLITE_PCache_GetSize (sqlite3_pcache *pcache)
 Get number of pages stored in cache.
static void * s_SQLITE_PCache_GetPage (sqlite3_pcache *pcache, unsigned int key, int createFlag)
 Get page from cache.
static void s_SQLITE_PCache_UnpinPage (sqlite3_pcache *pcache, void *page, int discard)
 Release page (make it reusable by others).
static void s_SQLITE_PCache_Truncate (sqlite3_pcache *pcache, unsigned int iLimit)
 Truncate cache, delete all pages with keys greater or equal to given limit.
static void s_SQLITE_PCache_Destroy (sqlite3_pcache *pcache)
 Destroy cache instance.
static void * s_SQLITE_Mem_Malloc (int size)
 Allocate memory for SQLite.
static void s_SQLITE_Mem_Free (void *ptr)
 Free memory allocated for SQLite.
static void * s_SQLITE_Mem_Realloc (void *ptr, int new_size)
 Resize memory allocated for SQLite.
static int s_SQLITE_Mem_Size (void *ptr)
 Get size of memory allocated for SQLite.
static int s_SQLITE_Mem_Roundup (int size)
 Get size of memory that will be allocated if given size is requested.
static int s_SQLITE_Mem_Init (void *)
 Initialize memory managing module for SQLite.
static void s_SQLITE_Mem_Shutdown (void *)
 Deinitialize memory managing module for SQLite.
END_NCBI_SCOPE void * operator new (size_t size) throw (std::bad_alloc)
void operator delete (void *ptr) throw ()
void * operator new[] (size_t size) throw (std::bad_alloc)
void operator delete[] (void *ptr) throw ()
void * malloc (size_t size)
void free (void *ptr)
void * realloc (void *mem_ptr, size_t new_size)
void * calloc (size_t num, size_t size)

Variables

static const size_t kNCMMDefMemoryLimit = 1024 * 1024 * 1024
 Default global limit on memory consumption.
static const unsigned int kNCMMMaxSmallSize
 Maximum size of small block (which is less than size of memory chunk) manager can allocate.
static const unsigned int kNCMMSmallSize [kNCMMCntSmallSizes]
 List of all distinct sizes of small blocks memory manager can allocate.
static unsigned int kNCMMSmallSizeIndex [kNCMMMaxSmallSize/8+1] = {0}
 List of indexes inside kNCMMSmallSize for each block size that can be requested.
static unsigned int kNCMMBlocksPerSet [kNCMMCntSmallSizes] = {0}
 Number of blocks that fits into one blocks set for each block size.
static unsigned int kNCMMBlocksPerGrade [kNCMMCntSmallSizes] = {0}
 Number of blocks that fits into one emptiness grade of blocks set.
static unsigned int kNCMMLostPerSet [kNCMMCntSmallSizes] = {0}
 Number of bytes lost at the end of blocks set for each block size.
static unsigned int kNCMMOverheadPerSet [kNCMMCntSmallSizes] = {0}
 Number of bytes used by manager in each blocks set (different for each block size).
static const unsigned int kNCMMChunksPerSlabGrade = kNCMMCntChunksInSlab / (kNCMMSlabEmptyGrades - 1) + 1
 Number of chunks in each slab's emptiness grade.
static const size_t kNCMMSizePoolArraySize = sizeof(CNCMMSizePool) * kNCMMCntSmallSizes
 Size of CNCMMSizePool[] array containing pools for each block size that memory manager can allocate.
static const int kNCMMSQLiteBigBlockMin = 2 * kNCMMChunkSize - kNCMMSetBaseSize
 "Magic" minimum size of block requested by SQLite that should be converted to allocation of maximum size - kNCMMSQLiteBigBlockReal.
static const int kNCMMSQLiteBigBlockReal = 2010000
 The real size of big block that will be allocated for SQLite if it requests for something greater than kNCMMSQLiteBigBlockMin.
static const int kNCMMDBHashSizeFactor = 8
 "The goal" for hash-table in database cache on the number of pages to have for each hash value.
static const int kNCMMBGThreadWaitSecs = 5
 Frequency of background thread iterations in seconds between them.
static const size_t kNCMMLimitToleranceChunks = 25
 Number of chunks that manager allows to be used on top of global limit for memory consumption.
static const size_t kNCMMMemPageSize = 4 * 1024
 Size of memory page that is a granularity of all allocations from OS.
static const size_t kNCMMMemPageAlignMask = ~(kNCMMMemPageSize - 1)
 Mask that can move pointer address or memory size to the memory page boundary.
static const int kNCMmapProtection = PROT_READ | PROT_WRITE
 Combination of flags used as "protection" parameter to mmap().
static sqlite3_pcache_methods s_NCDBCacheMethods
 All methods of database cache exposed to SQLite.
static sqlite3_mem_methods s_NCMallocMethods
 All methods of memory management exposed to SQLite.


Function Documentation

void* calloc size_t  num,
size_t  size
 

Definition at line 3356 of file nc_memory.cpp.

Referenced by _PSIAlignedBlockNew(), _PSIAllocateMatrix(), _PSICalculateInformationContentFromFreqRatios(), _PSICalculateInformationContentFromScoreMatrix(), _PSIInternalPssmDataNew(), _PSIMsaNew(), _PSIPackedMsaNew(), _PSISequenceWeightsNew(), bcp_init(), Blast_DiagnosticsInit(), Blast_ForbiddenRangesInitialize(), BLAST_GapAlignStructNew(), Blast_GetMatrixValues(), Blast_GetOneQueryStructs(), Blast_HitListNew(), Blast_HSPListNew(), Blast_HSPNew(), Blast_HSPResultsNew(), Blast_HSPStreamResultBatchInit(), BLAST_InitHitListNew(), Blast_KarlinBlkNew(), Blast_MessageWrite(), Blast_OptimizeTargetFrequencies(), Blast_PerrorEx(), BLAST_PrintAllowedValues(), BLAST_PrintMatrixMessage(), Blast_RedoAlignmentCore(), Blast_ResFreqNew(), Blast_ResFreqStdComp(), Blast_ScoreFreqNew(), BLAST_ScoreSetAmbigRes(), BlastAaLookupTableNew(), BlastCompo_HeapInitialize(), BlastCompressedAaLookupTableNew(), BlastDatabaseOptionsNew(), BlastEffectiveLengthsOptionsNew(), BlastEffectiveLengthsParametersNew(), BlastExtendWordNew(), BlastExtensionOptionsNew(), BlastExtensionParametersNew(), BlastFilteringOptionsFromString(), BlastFilteringOptionsToString(), BlastHitSavingOptionsNew(), BlastHitSavingParametersNew(), BlastHSPBestHitOptionsNew(), BlastHSPCullingOptionsNew(), BlastHSPFilteringOptionsNew(), BlastHSPStreamNew(), BlastInitialWordOptionsNew(), BlastInitialWordParametersNew(), BlastLinkHSPParametersNew(), BlastMaskLocNew(), BlastMBLookupTableNew(), BlastNaLookupTableNew(), BlastQueryInfoNew(), BlastQuerySetUpOptionsNew(), BlastResCompNew(), BlastScoreBlkNew(), BlastScoringOptionsNew(), BlastScoringParametersNew(), BlastSeqBlkNew(), BlastSeqBlkSetSeqRanges(), BlastSeqLocNew(), BlastSeqSrcIteratorNewEx(), BlastSeqSrcNew(), BlastSmallNaLookupTableNew(), BlastTargetTranslationNew(), BOOST_AUTO_TEST_CASE(), buffer_add_row(), buffer_alloc(), CBlastOptionsLocal::CBlastOptionsLocal(), CONN_Create(), cprl(), ct_get_data(), debruijn(), DSOCK_CreateEx(), DynamicInt4ArrayNew(), DynamicSGenCodeNodeArrayNew(), DynamicUint4ArrayNewEx(), GapEditScriptNew(), HEAP_AttachFast(), HINFO_Create(), impalaScaleMatrix(), ir_fp_entry_create(), ir_hash_create(), Kappa_compactSearchItemsNew(), Kappa_posSearchItemsNew(), ListNodeNew(), LookupTableOptionsNew(), LookupTableWrapInit(), main(), MatrixInfoNew(), CdPssmInput::moveUpLongestRow(), NewCorDef(), NewFldMtf(), NewGibScd(), NewQrySeq(), NewRcxPtl(), NewSeqMtf(), NewThdTbl(), Nlm_DenseMatrixNew(), Nlm_Int4MatrixNew(), Nlm_LtriangMatrixNew(), OffsetArrayToContextOffsets(), OrderThdTbl(), PHIBlast_HSPResultsSplit(), PHIGetPatternOccurrences(), PSIBlastOptionsNew(), PSIDiagnosticsRequestNew(), PSIDiagnosticsResponseNew(), RPSLookupTableNew(), RPSPsiMatrixAttach(), s_AA20alphaStd(), s_Accept(), s_Align(), s_BlastDiagTableNew(), s_BlastEvenGapLinkHSPs(), s_BlastGetTranslationTable(), s_BlastGreedyAlignMemAlloc(), s_BlastHSPBestHitInit(), s_BlastHSPCollectorRun(), s_BlastHSPCullingInit(), s_BlastNaLookupFinalize(), s_BlastSeqLocListToArrayOfPointers(), s_BlastSetUpAuxStructures(), s_CompOn(), s_Create(), s_CreateListening(), s_FillContigMBTable(), s_FillDiscMBTable(), s_FindHitsLong(), s_GetMatrixScoreProbs(), s_GetPssmScoreProbs(), s_GetQueryInfo(), s_LinkedHSPSetArrayIndexQueryEnds(), s_LinkedHSPSetArraySetUp(), s_LinkHSPStructReset(), s_Open(), s_OpenWin(), s_PackVeryLongPattern(), s_PatternSearchItemsInit(), s_PHIBlastAlignPatterns(), s_PHIGetLongPattern(), s_SavedParametersNew(), s_SegSeq(), s_SegsToBlastSeqLoc(), s_SeqEntropy(), s_SequenceGetProteinRange(), s_SetupScoringOptionsForReevaluateHSP(), s_SSequenceNew(), s_StateOn(), s_WindowsFromProteinAligns(), s_WindowsFromTranslatedAligns(), SBlastFilterOptionsNew(), SBlastProgressNew(), SBlastScoreMatrixNew(), SCompressedAlphabetNew(), SegParametersNewAa(), SERV_DISPD_Open(), SERV_LOCAL_Open(), SERVICE_CreateConnectorEx(), LinkHspTestFixture::setupCutoffScores(), CBlastExtendTestFixture::setupHitList(), LinkHspTestFixture::setupHitParams(), setupHSPList(), LinkHspTestFixture::setupHSPListForMiddleInsertTest(), LinkHspTestFixture::setupHSPListNucl(), LinkHspTestFixture::setupHSPListTransl(), slo0(), SMessageOriginNew(), SmithWatermanScoreWithTraceback(), SOCK_CreateOnTopEx(), SPHIPatternSearchBlkNew(), SPHIQueryInfoNew(), SplitQueryBlkNew(), SPsiBlastScoreMatrixNew(), SRepeatFilterOptionsNew(), SWindowMaskerOptionsNew(), tds7_build_param_def_from_params(), tds_build_param_def_from_params(), TRIGGER_Create(), CTracebackSearchTestFixture::x_GetSampleHspStream(), CTracebackSearchTestFixture::x_GetSelfHitHspStream(), CPhiblastTestFixture::x_SetupHSPList(), and zcalloc().

DEFINE_CLASS_STATIC_FAST_MUTEX CNCMMCentral::sm_CentralLock   ) 
 

void free void *  ptr  ) 
 

Definition at line 3344 of file nc_memory.cpp.

Referenced by __sfree(), _bcp_build_bulk_insert_stmt(), _bcp_exec_in(), _bcp_measure_terminated_field(), _blk_clean_desc(), _csclient_msg(), _ct_cmd_drop(), _ct_diag_clearmsg(), _ct_initialise_cmd(), _ctclient_msg(), _SQLAllocEnv(), _SQLAllocStmt(), _SQLFreeEnv(), _SQLFreeStmt(), _SQLGetDiagRec(), AlignmentFileFree(), CCharPtrFunctions< T >::Assign(), CTrSequence< bitst, bitsc >::Assign(), Blast_CompositionBasedStats(), Blast_CompositionWorkspaceFree(), Blast_ForbiddenRangesRelease(), Blast_MatrixInfoFree(), Blast_OptimizeTargetFrequencies(), Blast_RedoAlignParamsFree(), Blast_RedoAlignParamsNew(), BlastCompo_AlignmentsFree(), BlastCompo_HeapRelease(), BlastCompressedAaLookupTableDestruct(), blk_drop(), blk_init(), BOOST_AUTO_TEST_CASE(), bsClose(), BUF_Destroy(), BUF_Erase(), BUF_Read(), buffer_add_row(), change_database(), CBDB_Env::CleanLog(), CTrSequence< bitst, bitsc >::clear(), CTL_CursorResultExpl::ClearFields(), CONN_Close(), CONN_Create(), ConnNetInfo_DeleteAllArgs(), ConnNetInfo_Destroy(), ConnNetInfo_Log(), ConnNetInfo_SetupStandardArgs(), ConnNetInfo_SetUserHeader(), convert_tds2sql(), convert_to_usc2le_string(), convert_to_usc2le_string_free(), CBDB_RawFile::CountRecs(), cs_config(), cs_ctx_alloc(), cs_ctx_drop(), cs_diag_clearmsg(), cs_loc_drop(), ct_cmd_props(), ct_con_drop(), ct_con_props(), ct_connect(), ct_data_info(), ct_get_data(), ct_param(), ct_setparam(), dbclose(), dbclropt(), dbconvert(), dbfcmd(), dbrecftos(), dbrpcinit(), dbrpcparam(), dbsetopt(), dbsqlsend(), dbuse(), ddDifferenceResidues(), ddRemap(), bm::ptr_allocator::deallocate(), bm::block_allocator::deallocate(), default_bzfree(), CDeleter< X >::Delete(), desc_alloc(), desc_free(), CBDB_File::DestroyDBT_Clone(), ErrorInfoFree(), extend_inputline(), NStr::FormatVarargs(), free_linked_dbopt(), FreeCorDef(), FreeFldMtf(), FreeGibScd(), freeMatrix(), FreeQrySeq(), FreeRcxPtl(), FreeSeqMtf(), freeSet(), freeSubTree(), FreeThdTbl(), freeTree(), CDirEntry::GetTmpName(), HEAP_Detach(), ir_fp_entry_destroy(), ir_hash_destroy(), LOG_Delete(), LOG_WriteInternal(), LSOCK_Close(), main(), make_lm_v2_response(), MIME_ParseContentTypeEx(), CdPssmInput::moveUpLongestRow(), MT_LOCK_Delete(), CBDB_Env::MutexGetFree(), NcbiMessagePlusError(), new_free(), Nlm_DenseMatrixFree(), Nlm_DenseMatrixNew(), Nlm_Int4MatrixFree(), Nlm_Int4MatrixNew(), Nlm_LtriangMatrixNew(), NNIEdgeTest(), odbc_errs_pop(), odbc_errs_reset(), DBT_ptr::operator=(), param_clear(), pool_free(), CBDB_Env::PrintLockStat(), CBDB_Env::PrintMemStat(), CBDB_Env::PrintMutexStat(), CBDB_RawFile::PrintStat(), REG_Delete(), regexec(), ReNewtonSystemFree(), reset_save_context(), rpc_clear(), s_AddDeflineFromOrganismLine(), s_AddServerInfo(), s_AddSkipInfo(), s_AdjustNetParams(), s_AlignFileRawFree(), s_AlignRawSeqFree(), s_ClientAddress(), s_Close(), s_CloseAsnConn(), s_CommentLocFree(), s_ConvertDataToOutput(), s_CreateConnector(), s_Destroy(), s_FTPExecute(), s_GetNextInfo(), s_HEAP_Alloc(), s_HEAP_Collect(), s_HEAP_Free(), s_IntLinkFree(), s_IsContentTypeDefined(), s_IsUpdateNeeded(), s_LengthListFree(), s_LineInfoFree(), s_LineInfoReaderFree(), s_LoadServices(), s_LoadSingleService(), s_LOG_FileCleanup(), s_LOG_FileHandler(), s_MatchingSequenceRelease(), s_Open(), s_PreRead(), s_Read(), s_ReadAlignFileRaw(), s_ReadOrgNamesFromText(), s_ReplaceNexusTypeChar(), s_ReportError(), s_ReprocessIds(), s_Reset(), s_Resolve(), s_SavedParametersFree(), s_SequenceDataRelease(), s_SequenceGetTranslatedRange(), s_SetDefaultReferer(), s_SizeInfoFree(), s_SkipSkip(), s_StdGetTmpName(), s_StringCountFree(), s_Update(), s_VT_Open(), s_VT_Write(), s_WindowInfoFree(), s_WriteCommand(), search_interface_file(), SequenceInfoFree(), SERV_Close(), SERV_ServerPort(), SERV_Update(), SERVICE_CreateConnectorEx(), CNcbiEnvironment::Set(), CCharPtrFunctions< T >::SetDefault(), SOCK_CloseEx(), sql2tds(), stack_free(), string_to_datetime(), tdoGetIniFileName(), tds5_fix_dot_query(), tds7_send_auth(), tds_alloc_param_result(), tds_answer_challenge(), tds_convert_string(), tds_dstr_copy(), tds_dstr_copyn(), tds_dstr_free(), tds_dstr_set(), tds_free_bcp_column_data(), tds_free_connection(), tds_free_context(), tds_free_dynamic(), tds_free_locale(), tds_free_login(), tds_free_param_result(), tds_free_results(), tds_free_row(), tds_free_socket(), tds_get_home_file(), tds_get_locale(), tds_iconv_free(), tds_iconv_get_info(), tds_open_socket(), tds_parse_locale(), tds_process_auth(), tds_process_col_name(), tds_process_compute_names(), tds_process_compute_names_095(), tds_process_env_chg(), tds_process_login_tokens(), tds_read_conf_file(), tds_read_config_info(), tds_read_interfaces(), tds_release_cursor(), tds_submit_execdirect(), tds_submit_prepare(), tds_submit_query_params(), tds_submit_queryf(), tds_vstrbuild(), tdsdbopen(), TRIGGER_Close(), CNcbiEnvironment::Unset(), URL_ConnectEx(), vasprintf(), CObjectOStreamAsnBinary::WriteBitString(), zcfree(), CCgiApplication::~CCgiApplication(), CSeqDBAutoFree::~CSeqDBAutoFree(), CTrSequence< bitst, bitsc >::~CTrSequence(), DBT_ptr::~DBT_ptr(), SNetServiceImpl::~SNetServiceImpl(), SRotatedFontCachePurger::~SRotatedFontCachePurger(), and CSeqDB::TSequenceRanges::~TSequenceRanges().

void* malloc size_t  size  ) 
 

Definition at line 3338 of file nc_memory.cpp.

Referenced by _bcp_build_bulk_insert_stmt(), _bcp_exec_in(), _bcp_measure_terminated_field(), _blk_build_bulk_insert_stmt(), _ct_allocate_dynamic(), _ct_fill_param(), _PSIAlignedBlockNew(), _PSIAllocateMatrix(), _PSIMatrixFrequencyRatiosNew(), _PSIMsaNew(), _PSIPackedMsaNew(), _SQLAllocConnect(), _SQLAllocEnv(), _SQLAllocStmt(), AascanTestFixture::AascanTestFixture(), addToSet(), ALIGN_EX(), AlignmentFileNew(), bm::ptr_allocator::allocate(), bm::block_allocator::allocate(), CTrSequence< bitst, bitsc >::AppendItem(), CTrSequence< bitst, bitsc >::Assign(), bcp_bind(), bcp_colfmt(), bcp_columns(), bcp_init(), bcp_readfmt(), binary_to_result(), Blast_CompositionWorkspaceNew(), BLAST_CreateMixedFrameDNATranslation(), Blast_ForbiddenRangesInitialize(), BLAST_GapAlignStructNew(), BLAST_GetAllTranslations(), Blast_GetPartialTranslation(), BLAST_GetStandardAaProbabilities(), Blast_HSPGetTargetTranslation(), Blast_HSPResultsNew(), BLAST_InitHitListNew(), Blast_IntervalTreeInit(), Blast_MatrixInfoNew(), Blast_OptimizeTargetFrequencies(), BLAST_PackDNA(), Blast_RedoAlignParamsNew(), Blast_ScoreBlkMatrixFill(), Blast_SemiGappedAlign(), Blast_TracebackFromHSPList(), BlastCompo_AlignmentNew(), BlastCompressBlastnaSequence(), BlastCompressedAaLookupTableNew(), BlastHSPBestHitInfoNew(), BlastHSPBestHitParamsNew(), BlastHSPBestHitPipeInfoNew(), BlastHSPCollectorInfoNew(), BlastHSPCollectorParamsNew(), BlastHSPCullingInfoNew(), BlastHSPCullingParamsNew(), BlastHSPCullingPipeInfoNew(), BlastHSPListDup(), BlastHSPStreamNew(), BlastLookupAddWordHit(), BlastMemDup(), BlastSaveInitHsp(), BlastSeqSrcIteratorNewEx(), BlastTargetTranslationNew(), BLbasicSmithWatermanScoreOnly(), blk_alloc(), blk_init(), BLSmithWatermanFindStart(), BLspecialSmithWatermanFindStart(), BLspecialSmithWatermanScoreOnly(), bNNI(), BOOST_AUTO_TEST_CASE(), bsOpenReadStream(), bsOpenWriteStream(), BUF_SetChunkSize(), buildAveragesTable(), CEffectiveSearchSpacesMemento::CEffectiveSearchSpacesMemento(), change_database(), CBDB_File::CloneDBT_Key(), ConnNetInfo_Clone(), ConnNetInfo_Create(), ConnNetInfo_Log(), ConnNetInfo_URL(), ContextOffsetsToOffsetArray(), continue_parse_prepared_query(), convert_to_usc2le_string(), cs_config(), cs_ctx_alloc(), cs_diag_storemsg(), cs_loc_alloc(), ct_cmd_alloc(), ct_cmd_props(), ct_command(), ct_con_alloc(), ct_con_props(), ct_connect(), ct_data_info(), ct_diag_storeclientmsg(), ct_diag_storeservermsg(), ct_dynamic(), ct_param(), ct_setparam(), dbcmd(), dbprrow(), dbrpcinit(), dbrpcparam(), dbuse(), ddDifferenceResidues(), ddRemap(), default_bzalloc(), desc_alloc(), desc_alloc_records(), DSOCK_RecvMsg(), DSOCK_SendMsg(), ErrorInfoNew(), fastme_run(), FILE_CreateConnectorEx(), FTP_CreateDownloadConnector(), g_CORE_Sprintf(), GapPrelimEditBlockNew(), GetReverseNuclSequence(), AalookupTestFixture::GetSeqBlk(), GetSequenceNucleotideBothStrands(), GetSequenceProtein(), GetSequenceSingleNucleotideStrand(), HEAP_Copy(), HEAP_Create(), init_dboptions(), initDoubleMatrix(), initPerm(), ir_fp_entry_create(), ir_hash_create(), loadMatrix(), loadMatrixOLD(), loadNewickTree(), LOG_ComposeMessage(), LOG_Create(), LOG_ToFILE_Ex(), main(), make_lm_v2_response(), makeEdge(), makeNode(), MB_IndexedWordFinder(), MBSpaceNew(), MEMORY_CreateConnectorEx(), MIME_ParseContentTypeEx(), MT_LOCK_Create(), myMalloc(), NAMEDPIPE_CreateConnector(), NCBI_strdup(), NCBI_strndup(), NcbiMessagePlusError(), new_malloc(), NewickPrintTreeString(), newTree(), Nlm_DenseMatrixNew(), Nlm_Int4MatrixNew(), Nlm_LtriangMatrixNew(), NNI(), NNIEdgeTest(), norm_fmt(), odbc_errs_add(), odbc_errs_add_rdbms(), odbc_set_stmt(), DBT_ptr::operator=(), param_row_alloc(), paramrowalloc(), pcre_maketables(), pcregrep(), PIPE_CreateConnector(), pool_allocate(), pool_allocate2(), PSIMatrixNew(), PSIMsaNew(), CObjectIStreamAsnBinary::ReadCString(), REG_Create(), regexec(), ReNewtonSystemNew(), RPSRescalePssm(), s_AddDeflineFromOrganismLine(), s_AddLengthRepeat(), s_AddPSSMNeighboringWords(), s_AddService(), s_AdjustNetParams(), s_AdjustSubjectChunks(), s_Align(), s_AlignFileRawNew(), s_AlignRawSeqNew(), s_AllocChunk(), s_BlastAlignPackedNucl(), s_BlastEvenGapLinkHSPs(), s_BlastGreedyAlignMemAlloc(), s_BlastHSPBestHitNew(), s_BlastHSPBestHitPipeNew(), s_BlastHSPCollectorNew(), s_BlastHSPCullingNew(), s_BlastHSPCullingPipeNew(), s_BlastHSPListsCombineByScore(), s_BlastSetUpAuxStructures(), s_BlastUnevenGapLinkHSPs(), s_BracketedCommentListNew(), s_ClientAddress(), s_CompressedListGetNewCell(), s_ConvertDataToOutput(), s_CreateAnchorPatternForMarkedIDs(), s_CreateConnector(), s_CreateOrderedOrgName(), s_Dns_Write(), s_DoesBlockHaveIds(), s_FindComment(), s_Firewall_Write(), s_FTPExecute(), s_GapGetState(), s_GappingParamsNew(), s_GetIdFromString(), s_GetNode(), s_HSPCopy(), s_Http_Write(), s_Init(), s_IntLinkNew(), s_IsContentTypeDefined(), s_LengthListNew(), s_LineInfoNew(), s_LineInfoReaderNew(), s_LinkedHSPSetArraySetUp(), s_LoadSingleService(), s_MatchingSequenceInitialize(), s_MatrixInfoInit(), s_MergeLinkedHSPSets(), s_ModifyUserHeader(), s_Ncbid_Write(), s_NuclSmithWaterman(), s_OutOfFrameAlignWithTraceback(), s_OutOfFrameGappedAlign(), s_Read(), s_ReadHeader(), s_ReplaceNexusTypeChar(), s_ReportASN1Error(), s_ReportBadCharError(), s_ReportBadNumSegError(), s_ReportBadSequenceLength(), s_ReportBlockLengthError(), s_ReportCharCommentError(), s_ReportDefinitionLines(), s_ReportIncorrectNumberOfSequences(), s_ReportIncorrectSequenceLength(), s_ReportLineLengthError(), s_ReportOrgCommentError(), s_ReportRepeatedId(), s_ReportRepeatedOrganismName(), s_ReportUnusedLine(), s_RestrictedGappedAlign(), s_RPSGapAlignDataPrepare(), s_SavedParametersNew(), s_SeqDbGetNextChunk(), s_SetAsnConn_CloseCb(), s_SetDefaultReferer(), s_SizeInfoNew(), s_SmithWatermanScoreOnly(), s_Standalone_Write(), s_StringCountNew(), s_StripToPattern(), s_TrimResultsByTotalHSPLimit(), s_VT_Descr(), s_VT_Open(), s_VT_Write(), s_WindowInfoNew(), s_WriteCommand(), SBlastHitsParametersDup(), SBlastHitsParametersNew(), SCompressedAlphabetNew(), SDustOptionsNew(), search_interface_file(), SequenceInfoNew(), SERV_CopyInfoEx(), SERV_CreateDnsInfoEx(), SERV_CreateFirewallInfoEx(), SERV_CreateHttpInfoEx(), SERV_CreateNcbidInfoEx(), SERV_CreateStandaloneInfoEx(), SERV_Update(), SERVICE_CreateConnectorEx(), CBlastOptionsLocal::SetEffectiveSearchSpace(), TestFixture::SetUpLookupTable(), CPrimitiveTypeInfoCharPtr< T >::SetValueChar(), SmithWatermanScoreWithTraceback(), SplitQueryBlk_GetContextOffsetsForChunk(), SplitQueryBlk_GetQueryContextsForChunk(), SplitQueryBlk_GetQueryIndicesForChunk(), SQLTables(), SSegOptionsNew(), stack_malloc(), strdup(), string_to_datetime(), string_to_result(), tds5_fix_dot_query(), tds7_build_param_def_from_params(), tds7_build_param_def_from_query(), tds_alloc_compute_results(), tds_alloc_compute_row(), tds_alloc_context(), tds_alloc_dynamic(), tds_alloc_get_string(), tds_alloc_locale(), tds_alloc_login(), tds_alloc_param_result(), tds_alloc_param_row(), tds_alloc_row(), tds_build_param_def_from_params(), tds_build_param_def_from_query(), tds_convert_binary(), tds_convert_bit(), tds_convert_char(), tds_convert_string(), tds_dstr_copyn(), tds_get_data(), tds_get_dynid(), tds_iconv_alloc(), tds_iconv_get_info(), tds_process_auth(), tds_process_col_name(), tds_process_compute_names(), tds_process_compute_names_095(), tds_process_msg(), tds_read_packet(), tds_strftime(), tds_vstrbuild(), tdsdbopen(), URL_ConnectEx(), vasprintf(), CObjectOStreamAsnBinary::WriteBitString(), CSeqDBVol::x_AllocType(), CSeqDBAtlas::x_GetRegion(), CTracebackSearchTestFixture::x_GetSampleHspStream(), CTracebackSearchTestFixture::x_GetSelfHitHspStream(), CPssmEngine::x_GuardProteinQuery(), CPhiblastTestFixture::x_SetupSequenceBlk(), and zcalloc().

void operator delete void *  ptr  )  throw ()
 

Definition at line 3280 of file nc_memory.cpp.

void operator delete[] void *  ptr  )  throw ()
 

Definition at line 3297 of file nc_memory.cpp.

END_NCBI_SCOPE void* operator new size_t  size  )  throw (std::bad_alloc)
 

Definition at line 3269 of file nc_memory.cpp.

Referenced by CNCMMDBCache::operator new().

void* operator new[] size_t  size  )  throw (std::bad_alloc)
 

Definition at line 3286 of file nc_memory.cpp.

void* realloc void *  mem_ptr,
size_t  new_size
 

Definition at line 3350 of file nc_memory.cpp.

Referenced by CTrSequence< bitst, bitsc >::AppendItem(), BLAST_FillEffectiveLengthsOptions(), Blast_ForbiddenRangesPush(), Blast_HSPListAppend(), Blast_HSPListSaveHSP(), BLAST_SaveInitialHit(), BlastHSPStreamClose(), BlastLookupAddWordHit(), ConnNetInfo_AppendUserHeader(), continue_parse_prepared_query(), ct_command(), dbcmd(), desc_alloc_records(), DynamicUint4Array_Copy(), CSeqDBGiMask::GetMaskData(), NcbiMessagePlusError(), odbc_errs_add(), odbc_errs_add_rdbms(), SReadInt4::Read(), CSeqDB::TSequenceRanges::reserve(), s_AddService(), s_AddToRPSBucket(), s_Blast_HitListGrowHSPListArray(), s_BlastDiagHashInsert(), s_BlastHSPCollectorRun(), s_CompHeapRecordInsertAtEnd(), s_DynamicInt4Array_ReallocIfNecessary(), s_DynamicSGenCodeNodeArray_ReallocIfNecessary(), s_DynamicUint4Array_ReallocIfNecessary(), s_GapPrelimEditBlockRealloc(), s_IntervalNodeInit(), s_MatrixDataReset(), s_ModifyUserHeader(), s_Open(), s_PHIBlastAddPatternHit(), s_SafeStrCat(), tds5_fix_dot_query(), tds_alloc_compute_results(), tds_alloc_get_string(), tds_alloc_param_result(), tds_alloc_param_row(), tds_free_param_result(), tds_get_data(), tds_iconv_get_info(), tds_read_packet(), and tds_realloc_socket().

static unsigned int s_GetCntPerGrade unsigned int  total,
unsigned int  grades
[inline, static]
 

Get number of blocks (or something else) per each emptiness grade when given total number of blocks and number of grades.

Definition at line 232 of file nc_memory.cpp.

Referenced by CNCMMCentral::x_Initialize().

static unsigned int s_GetGradeValue unsigned int  cur_cnt,
unsigned int  cnt_per_grade
[inline, static]
 

Get emptiness grade value when given current number of blocks (or something else) and number of blocks per each grade.

Definition at line 240 of file nc_memory.cpp.

Referenced by CNCMMSlab::x_CalcEmptyGrade(), and CNCMMBlocksSet::x_CalcEmptyGrade().

static void s_SQLITE_Mem_Free void *  ptr  )  [static]
 

Free memory allocated for SQLite.

Definition at line 3144 of file nc_memory.cpp.

References CNCMMCentral::DeallocMemory().

static int s_SQLITE_Mem_Init void *   )  [static]
 

Initialize memory managing module for SQLite.

Definition at line 3172 of file nc_memory.cpp.

static void* s_SQLITE_Mem_Malloc int  size  )  [static]
 

Allocate memory for SQLite.

Definition at line 3129 of file nc_memory.cpp.

References _ASSERT, CNCMMCentral::AllocMemory(), kNCMMSQLiteBigBlockMin, and kNCMMSQLiteBigBlockReal.

static void* s_SQLITE_Mem_Realloc void *  ptr,
int  new_size
[static]
 

Resize memory allocated for SQLite.

Definition at line 3151 of file nc_memory.cpp.

References CNCMMCentral::ReallocMemory().

static int s_SQLITE_Mem_Roundup int  size  )  [static]
 

Get size of memory that will be allocated if given size is requested.

Definition at line 3165 of file nc_memory.cpp.

static void s_SQLITE_Mem_Shutdown void *   )  [static]
 

Deinitialize memory managing module for SQLite.

Definition at line 3179 of file nc_memory.cpp.

static int s_SQLITE_Mem_Size void *  ptr  )  [static]
 

Get size of memory allocated for SQLite.

Definition at line 3158 of file nc_memory.cpp.

References CNCMMCentral::GetMemorySize().

static sqlite3_pcache* s_SQLITE_PCache_Create int  szPage,
int  bPurgeable
[static]
 

Create new cache instance.

Definition at line 3076 of file nc_memory.cpp.

static void s_SQLITE_PCache_Destroy sqlite3_pcache *  pcache  )  [static]
 

Destroy cache instance.

Definition at line 3122 of file nc_memory.cpp.

static void* s_SQLITE_PCache_GetPage sqlite3_pcache *  pcache,
unsigned int  key,
int  createFlag
[static]
 

Get page from cache.

Definition at line 3098 of file nc_memory.cpp.

static int s_SQLITE_PCache_GetSize sqlite3_pcache *  pcache  )  [static]
 

Get number of pages stored in cache.

Definition at line 3091 of file nc_memory.cpp.

static int s_SQLITE_PCache_Init void *   )  [static]
 

Initialize database cache.

Definition at line 3064 of file nc_memory.cpp.

static void s_SQLITE_PCache_SetSize sqlite3_pcache *  pcache,
int  nCachesize
[static]
 

Set size of database cache (number of pages).

Definition at line 3084 of file nc_memory.cpp.

static void s_SQLITE_PCache_Shutdown void *   )  [static]
 

Deinitialize database cache.

Definition at line 3071 of file nc_memory.cpp.

static void s_SQLITE_PCache_Truncate sqlite3_pcache *  pcache,
unsigned int  iLimit
[static]
 

Truncate cache, delete all pages with keys greater or equal to given limit.

Definition at line 3115 of file nc_memory.cpp.

static void s_SQLITE_PCache_UnpinPage sqlite3_pcache *  pcache,
void *  page,
int  discard
[static]
 

Release page (make it reusable by others).

Definition at line 3108 of file nc_memory.cpp.


Variable Documentation

const int kNCMmapProtection = PROT_READ | PROT_WRITE [static]
 

Combination of flags used as "protection" parameter to mmap().

Definition at line 177 of file nc_memory.cpp.

Referenced by CNCMMCentral::x_DoCallMmap().

const int kNCMMBGThreadWaitSecs = 5 [static]
 

Frequency of background thread iterations in seconds between them.

Definition at line 153 of file nc_memory.cpp.

Referenced by CNCMMCentral::x_DoBackgroundWork().

unsigned int kNCMMBlocksPerGrade[kNCMMCntSmallSizes] = {0} [static]
 

Number of blocks that fits into one emptiness grade of blocks set.

Array is initialized during manager initialization.

Definition at line 113 of file nc_memory.cpp.

Referenced by CNCMMBlocksSet::x_CalcEmptyGrade(), and CNCMMCentral::x_Initialize().

unsigned int kNCMMBlocksPerSet[kNCMMCntSmallSizes] = {0} [static]
 

Number of blocks that fits into one blocks set for each block size.

Array is initialized during manager initialization.

Definition at line 110 of file nc_memory.cpp.

Referenced by CNCMMBlocksSet::CNCMMBlocksSet(), CNCMMSizePool::x_DeallocateBlock(), CNCMMCentral::x_Initialize(), and CNCMMBlocksSet::~CNCMMBlocksSet().

const unsigned int kNCMMChunksPerSlabGrade = kNCMMCntChunksInSlab / (kNCMMSlabEmptyGrades - 1) + 1 [static]
 

Number of chunks in each slab's emptiness grade.

The formula is taken from s_GetCntPerGrade() and should be exact copy of it. It's repeated here just to make this a compile-time constant.

Definition at line 126 of file nc_memory.cpp.

Referenced by CNCMMSlab::x_CalcEmptyGrade().

const int kNCMMDBHashSizeFactor = 8 [static]
 

"The goal" for hash-table in database cache on the number of pages to have for each hash value.

Definition at line 151 of file nc_memory.cpp.

Referenced by CNCMMDBPagesHash::SetOptimalSize().

const size_t kNCMMDefMemoryLimit = 1024 * 1024 * 1024 [static]
 

Default global limit on memory consumption.

Definition at line 85 of file nc_memory.cpp.

Referenced by CNCMMCentral::SetMemLimits().

const size_t kNCMMLimitToleranceChunks = 25 [static]
 

Number of chunks that manager allows to be used on top of global limit for memory consumption.

Definition at line 156 of file nc_memory.cpp.

Referenced by CNCMMCentral::x_CalcMemoryMode().

unsigned int kNCMMLostPerSet[kNCMMCntSmallSizes] = {0} [static]
 

Number of bytes lost at the end of blocks set for each block size.

Array is initialized during manager initialization.

Definition at line 116 of file nc_memory.cpp.

Referenced by CNCMMStats::BlocksSetCreated(), CNCMMStats::BlocksSetDeleted(), and CNCMMCentral::x_Initialize().

const unsigned int kNCMMMaxSmallSize [static]
 

Initial value:

Maximum size of small block (which is less than size of memory chunk) manager can allocate.

Definition at line 88 of file nc_memory.cpp.

Referenced by CNCMMSizePool::AllocateBlock(), CNCMMCentral::AllocMemory(), and CNCMMCentral::DeallocMemory().

const size_t kNCMMMemPageAlignMask = ~(kNCMMMemPageSize - 1) [static]
 

Mask that can move pointer address or memory size to the memory page boundary.

Definition at line 163 of file nc_memory.cpp.

Referenced by CNCMMCentral::x_AlignSizeToPage().

const size_t kNCMMMemPageSize = 4 * 1024 [static]
 

Size of memory page that is a granularity of all allocations from OS.

Definition at line 160 of file nc_memory.cpp.

Referenced by CNCMMCentral::x_AlignSizeToPage().

unsigned int kNCMMOverheadPerSet[kNCMMCntSmallSizes] = {0} [static]
 

Number of bytes used by manager in each blocks set (different for each block size).

Memory mentioned is used by manager as opposed to the one used by real data requested by outside user. Array is initialized during manager initialization.

Definition at line 121 of file nc_memory.cpp.

Referenced by CNCMMStats::BlocksSetCreated(), CNCMMStats::BlocksSetDeleted(), and CNCMMCentral::x_Initialize().

const size_t kNCMMSizePoolArraySize = sizeof(CNCMMSizePool) * kNCMMCntSmallSizes [static]
 

Size of CNCMMSizePool[] array containing pools for each block size that memory manager can allocate.

This array is allocated for each thread (up to kNCMMMaxThreadsCnt instances).

Definition at line 132 of file nc_memory.cpp.

Referenced by CNCMMSizePool_Getter::CreateTlsObject(), and CNCMMSizePool_Getter::DeleteTlsObject().

const unsigned int kNCMMSmallSize[kNCMMCntSmallSizes] [static]
 

Initial value:

    { 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 96, 112, 128, 152, 176, 208, 248,
      296, 352, 416, 496, 592, 704, 840, 1008, 1208, 1448, 1736, 2080, 2496,
      (kNCMMSetDataSize / 11 - kNCMMBlockExtraSize) & ~7,
      (kNCMMSetDataSize / 9  - kNCMMBlockExtraSize) & ~7,
      (kNCMMSetDataSize / 8  - kNCMMBlockExtraSize) & ~7,
      (kNCMMSetDataSize / 7  - kNCMMBlockExtraSize) & ~7,
      (kNCMMSetDataSize / 6  - kNCMMBlockExtraSize) & ~7,
      (kNCMMSetDataSize / 5  - kNCMMBlockExtraSize) & ~7,
      (kNCMMSetDataSize / 4  - kNCMMBlockExtraSize) & ~7,
      (kNCMMSetDataSize / 3  - kNCMMBlockExtraSize) & ~7,
      kNCMMMaxSmallSize }
List of all distinct sizes of small blocks memory manager can allocate.

Definition at line 91 of file nc_memory.cpp.

Referenced by CNCMMBlocksSet::CNCMMBlocksSet(), CNCMMBlocksSetBase::GetBlockSize(), CNCMMStats::MemBlockAlloced(), CNCMMStats::MemBlockFreed(), CNCMMStats::Print(), CNCMMSizePool::x_DeallocateBlock(), and CNCMMCentral::x_Initialize().

unsigned int kNCMMSmallSizeIndex[kNCMMMaxSmallSize/8+1] = {0} [static]
 

List of indexes inside kNCMMSmallSize for each block size that can be requested.

Indexes are stored for each size divided by 8 because non-divisible sizes will not be allocated anyway. Array is initialized during manager initialization.

Definition at line 107 of file nc_memory.cpp.

Referenced by CNCMMSizePool::AllocateBlock().

const int kNCMMSQLiteBigBlockMin = 2 * kNCMMChunkSize - kNCMMSetBaseSize [static]
 

"Magic" minimum size of block requested by SQLite that should be converted to allocation of maximum size - kNCMMSQLiteBigBlockReal.

This constant basically means that on any request from SQLite for allocation of chunks chain with more than 2 chunks the actual allocation will contain at least kNCMMSQLiteBigBlockReal bytes.

See also:
kNCMMSQLiteBigBlockReal, s_SQLITE_Mem_Malloc

Definition at line 142 of file nc_memory.cpp.

Referenced by s_SQLITE_Mem_Malloc().

const int kNCMMSQLiteBigBlockReal = 2010000 [static]
 

The real size of big block that will be allocated for SQLite if it requests for something greater than kNCMMSQLiteBigBlockMin.

See also:
kNCMMSQLiteBigBlockMin, s_SQLITE_Mem_Malloc

Definition at line 147 of file nc_memory.cpp.

Referenced by s_SQLITE_Mem_Malloc().

sqlite3_pcache_methods s_NCDBCacheMethods [static]
 

Initial value:

All methods of database cache exposed to SQLite.

Definition at line 3184 of file nc_memory.cpp.

sqlite3_mem_methods s_NCMallocMethods [static]
 

Initial value:

All methods of memory management exposed to SQLite.

Definition at line 3199 of file nc_memory.cpp.


Generated on Mon Dec 7 07:23:28 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:21:42 2009 by modify_doxy.py rev. 173732