private IncrementingPollingCounter? _monitorContentionCounter;
private PollingCounter? _threadPoolQueueCounter;
private IncrementingPollingCounter? _completedItemsCounter;
+ private PollingCounter? _assemblyCounter;
private const int EnabledPollingIntervalMilliseconds = 1000; // 1 second
_monitorContentionCounter = _monitorContentionCounter ?? new IncrementingPollingCounter("monitor-lock-contention-count", this, () => Monitor.LockContentionCount) { DisplayName = "Monitor Lock Contention Count", DisplayRateTimeScale = new TimeSpan(0, 0, 1) };
_threadPoolQueueCounter = _threadPoolQueueCounter ?? new PollingCounter("threadpool-queue-length", this, () => ThreadPool.PendingWorkItemCount) { DisplayName = "ThreadPool Queue Length" };
_completedItemsCounter = _completedItemsCounter ?? new IncrementingPollingCounter("threadpool-completed-items-count", this, () => ThreadPool.CompletedWorkItemCount) { DisplayName = "ThreadPool Completed Work Item Count", DisplayRateTimeScale = new TimeSpan(0, 0, 1) };
+ _assemblyCounter = _assemblyCounter ?? new PollingCounter("assembly-count", this, () => System.Reflection.Assembly.GetAssemblyCount()) { DisplayName = "Number of Assemblies Loaded" };
}
}
}
// Exists to faciliate code sharing between CoreCLR and CoreRT.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal bool IsRuntimeImplemented() => this is RuntimeAssembly;
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ internal static extern uint GetAssemblyCount();
}
}
// to help your debugging.
DWORD g_dwLoaderReasonForNotSharing = 0; // See code:DomainFile::m_dwReasonForRejectingNativeImage for a similar variable.
+volatile uint32_t g_cAssemblies = 0;
+
// These will sometimes result in a crash with error code 0x80131401 SECURITY_E_INCOMPATIBLE_SHARE
// "Loading this assembly would produce a different grant set from other instances."
enum ReasonForNotSharing
#endif
m_pManifest = Module::Create(this, mdFileNil, GetManifestFile(), pamTracker);
+ FastInterlockIncrement((LONG*)&g_cAssemblies);
+
PrepareModuleForAssembly(m_pManifest, pamTracker);
CacheManifestFiles();
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_TRIGGERS;
STATIC_CONTRACT_FORBID_FAULT;
+
#ifdef PROFILING_SUPPORTED
if (CORProfilerTrackAssemblyLoads())
{
m_pClassLoader = NULL;
}
+ FastInterlockDecrement((LONG*)&g_cAssemblies);
+
#ifdef PROFILING_SUPPORTED
if (CORProfilerTrackAssemblyLoads())
{
return retVal;
}
+extern volatile uint32_t g_cAssemblies;
+
+FCIMPL0(uint32_t, AssemblyNative::GetAssemblyCount)
+{
+ FCALL_CONTRACT;
+
+ return g_cAssemblies;
+}
+FCIMPLEND
+
void QCALLTYPE AssemblyNative::GetModule(QCall::AssemblyHandle pAssembly, LPCWSTR wszFileName, QCall::ObjectHandleOnStack retModule)
{
QCALL_CONTRACT;
static BOOL QCALLTYPE GetIsCollectible(QCall::AssemblyHandle pAssembly);
+ static FCDECL0(uint32_t, GetAssemblyCount);
+
//
// PEFile QCalls
//
FCFuncStart(gAssemblyFuncs)
QCFuncElement("GetEntryAssemblyNative", AssemblyNative::GetEntryAssembly)
QCFuncElement("GetExecutingAssemblyNative", AssemblyNative::GetExecutingAssembly)
+ FCFuncElement("GetAssemblyCount", AssemblyNative::GetAssemblyCount)
FCFuncEnd()
FCFuncStart(gAssemblyBuilderFuncs)