public IB Reserve(AllocationInfo allocationInfo) { amapRegionUpdater.Update( allocationInfo.MapOffset, map => { var bits = map.Data.Value.ToBits(); for (var i = allocationInfo.BitStartIndex; i <= allocationInfo.BitEndIndex; i++) { bits[i] = 1; } var bytes = bits.ToBytes(); return (new AMap( BinaryData.OfValue(bytes), new PageTrailer( Constants.ptypeAMap, Constants.ptypeAMap, 0x0000, Crc32.ComputeCrc32(bytes), BID.OfValue(allocationInfo.MapOffset)))); }); var allocateSize = (allocationInfo.BitEndIndex - allocationInfo.BitStartIndex + 1) * 64; headerUsageProvider.Use(header => header.SetRoot(header.Root.SetFreeSpaceInAllAMaps(header.Root.AMapFree - allocateSize))); return(IB.OfValue(allocationInfo.MapOffset + allocationInfo.BitStartIndex * 64)); }
public override void Free(AllocationInfo allocation) { ThrowIfDisposed(); NativeMethods.HeapFree(processHeap, NativeMethods.HeapFreeFlags.HEAP_NO_FLAGS, allocation.Address); allocations.TryRemove(allocation); }
//public so we can run tests public static List <Document> CalcStudentDocuments(AllocationInfo ai, string ip, Random r) { var assignments = new List <Document>(); //for each question in this exam foreach (var docs in ai.Documents.Where(d => d.Count > 0)) { //how many times should we repeat each var repeatCount = (int)Math.Ceiling((float)ai.StudentCount / docs.Count); var repeatCounts = Enumerable.Repeat(repeatCount, docs.Count).ToList(); //reduce that by the number of times each has already been assigned for (var i = 0; i < docs.Count; i++) { if (ai.Assignments.TryGetValue(docs[i].Id, out var curAssignments)) { repeatCounts[i] -= curAssignments.Count; } } //reduce to zero if someone at the same IP address has already been assigned this document var ipRepeatCounts = new List <int>(); for (var i = 0; i < docs.Count; i++) { ipRepeatCounts.Add(repeatCounts[i]); if (ai.Assignments.TryGetValue(docs[i].Id, out var curAssignments)) { if (curAssignments.Any(a => a.Ip == ip)) { ipRepeatCounts[i] = 0; } } } //if this hasn't removed all possibilities, then take the more restrictive option //if everyone is in the same classroom (and thus same IP) this ensures that there are //still items to distribute if (ipRepeatCounts.Sum() > 0) { repeatCounts = ipRepeatCounts; } //create a pool of unassigned documents var docPool = new List <Document>(); for (var i = 0; i < repeatCounts.Count; i++) { for (var j = 0; j < repeatCounts[i]; j++) { docPool.Add(docs[i]); } } //assign a random document from the remaining pool to the student assignments.Add(docPool[r.Next(docPool.Count)]); } return(assignments); }
public override void Free(AllocationInfo allocation) { ThrowIfDisposed(); NativeMethods.VirtualFree((byte*)allocation.Address, UIntPtr.Zero, NativeMethods.FreeType.MEM_RELEASE | NativeMethods.FreeType.MEM_DECOMMIT); allocations.TryRemove(allocation); }
public override AllocationInfo Allocate(uint size) { ThrowIfDisposed(); var ptr = NativeMethods.HeapAlloc(processHeap, NativeMethods.HeapAllocFlags.HEAP_ZERO_MEMORY | NativeMethods.HeapAllocFlags.HEAP_GENERATE_EXCEPTIONS, new UIntPtr(size)); var allocation = new AllocationInfo(size, ptr); allocations.Add(allocation); return allocation; }
public IActionResult Post([FromBody] AllocationInfo info) { if (!ProjectIsActive(info.ProjectId)) { return(new StatusCodeResult(304)); } var record = _gateway.Create(info.ProjectId, info.UserId, info.FirstDay, info.LastDay); var value = new AllocationInfo(record.Id, record.ProjectId, record.UserId, record.FirstDay, record.LastDay, "allocation info"); return(Created($"allocations/{value.Id}", value)); }
public override AllocationInfo ReAllocate(uint newSize, AllocationInfo existingAllocation) { ThrowIfDisposed(); var ptr = NativeMethods.HeapReAlloc(processHeap, NativeMethods.HeapReallocFlags.HEAP_ZERO_MEMORY, existingAllocation.Address, new UIntPtr(newSize)); var allocation = new AllocationInfo(newSize, (void*)ptr); allocations.TryRemove(existingAllocation); allocations.Add(allocation); return allocation; }
protected override void OnEventWritten(EventWrittenEventArgs eventData) { switch (eventData.EventName) { case "GCAllocationTick_V3": var type = (string)eventData.Payload[5]; if (_allocations.TryGetValue(type, out var info) == false) { _allocations[type] = info = new AllocationInfo { Type = type }; } info.Allocations += (ulong)eventData.Payload[3]; break; } }
public override unsafe bool TryAllocate(void* requestedAddress, uint size, out AllocationInfo? allocation) { ThrowIfDisposed(); allocation = null; var ptr = NativeMethods.VirtualAlloc((byte*)requestedAddress, new UIntPtr(size), NativeMethods.AllocationType.COMMIT | NativeMethods.AllocationType.RESERVE, NativeMethods.MemoryProtection.READWRITE); if (ptr == (byte*)0) return false; allocation = new AllocationInfo(size, ptr); allocations.Add(allocation.Value); return true; }
public override AllocationInfo Allocate(uint size) { ThrowIfDisposed(); //here size is rounded by VirtualAlloc to system page size var ptr = NativeMethods.VirtualAlloc(null, new UIntPtr(size), NativeMethods.AllocationType.COMMIT | NativeMethods.AllocationType.RESERVE, NativeMethods.MemoryProtection.READWRITE); AssertNotNullPtr(ptr); var allocation = new AllocationInfo(size, ptr); NativeMethods.memset(ptr, 0, (int)size); allocations.Add(allocation); return allocation; }
/// <summary> /// </summary> /// <param name="model"></param> /// <param name="cls"></param> /// <param name="bscls"></param> /// <param name="xml"></param> public override SqlObject Setup(PersistentModel model, PersistentClass cls, IBSharpClass bscls, XElement xml) { base.Setup(model, cls, bscls, xml); Allocation = cls.AllocationInfo; FileGroup = Allocation.FileGroup.Name; Name = cls.FullSqlName.Replace(".", "_").Replace("\"", "") + "_PARTITION"; Start = Allocation.PartitioningStart; if (null != Allocation.PartitionField) { Type = Allocation.PartitionField.DataType.ResolveSqlDataType(DbDialect.SqlServer); } else { Type = "int"; } return(this); }
/// <summary> Performs a deep copy of the relevant data structures. </summary> public FStreamSnapshot DeepCopy(Dictionary <ulong, FLiveAllocationInfo> PointerToPointerInfoMap) { // Create new snapshot object. FStreamSnapshot Snapshot = new FStreamSnapshot("Copy"); // Manually perform a deep copy of LifetimeCallstackList foreach (FCallStackAllocationInfo AllocationInfo in LifetimeCallStackList) { Snapshot.LifetimeCallStackList[AllocationInfo.CallStackIndex] = AllocationInfo.DeepCopy(); } Snapshot.AllocationCount = AllocationCount; Snapshot.AllocationSize = AllocationSize; Snapshot.AllocationMaxSize = AllocationMaxSize; Snapshot.FinalizeSnapshot(PointerToPointerInfoMap); // Return deep copy of this snapshot. return(Snapshot); }
private static async Task <AllocationInfo> collectAllocationInfo(AppDbContext db, Student student, Exam exam) { var ai = new AllocationInfo { StudentCount = await db.Students.CountAsync(s => s.CourseId == student.CourseId) }; var questions = await db.Questions.Where(q => q.ExamId == exam.Id).ToListAsync(); foreach (var question in questions) { var docs = await db.Documents.Where(d => d.QuestionId == question.Id).ToListAsync(); //get the documents for this question ai.Documents.Add(docs); foreach (var doc in docs) { ai.Assignments.Add(doc.Id, (await db.Assignments.Where(a => a.DocumentId == doc.Id).ToListAsync()).Distinct().ToList()); } } return(ai); }
public abstract bool TryAllocate(void* requestedAddress, uint size, out AllocationInfo? allocation);
public ActionResult <bool> AllocateBook([FromBody] AllocationInfo request, [FromServices] IBooksManager booksManager) { var result = booksManager.AllocateBook(request.BookId, request.UserId, request.Method); return(result); }
public static void ParseSnapshot(TreeView CallGraphTreeView, List <FCallStackAllocationInfo> CallStackList, bool bShouldSortBySize, string FilterText, bool bInvertCallStacks) { // Progress bar. OwnerWindow.ToolStripProgressBar.Value = 0; OwnerWindow.ToolStripProgressBar.Visible = true; long ProgressInterval = CallStackList.Count / 20; long NextProgressUpdate = ProgressInterval; int CallStackCurrent = 0; OwnerWindow.UpdateStatus("Updating call graph for " + OwnerWindow.CurrentFilename); CallGraphTreeView.BeginUpdate(); CallGraphTreeView.TreeViewNodeSorter = null; // clear this to avoid a Sort for each call to Add Debug.WriteLine("FCallGraphTreeViewParser.ParseSnapshot - Building call graph tree for " + OwnerWindow.CurrentFilename); var TruncatedNode = new FCallGraphNode("Truncated Callstacks"); var RegularNode = new FCallGraphNode("Full Callstacks"); bool bFilterIn = OwnerWindow.IsFilteringIn(); using (FScopedLogTimer ParseTiming = new FScopedLogTimer("FCallGraphTreeViewParser.ParseSnapshot")) { var FilteredCallstackList = new List <FCallStackAllocationInfo>(CallStackList.Count); foreach (var AllocationInfo in CallStackList) { var FilteredAllocationInfo = AllocationInfo.GetAllocationInfoForTags(OwnerWindow.GetTagsFilter(), bFilterIn); if (FilteredAllocationInfo.TotalCount != 0) { FilteredCallstackList.Add(FilteredAllocationInfo); } } // Iterate over all call graph paths and add them to the graph. foreach (FCallStackAllocationInfo AllocationInfo in FilteredCallstackList) { // Update progress bar. if (CallStackCurrent >= NextProgressUpdate) { OwnerWindow.ToolStripProgressBar.PerformStep(); NextProgressUpdate += ProgressInterval; Debug.WriteLine("FCallGraphTreeViewParser.ParseSnapshot " + OwnerWindow.ToolStripProgressBar.Value + "/20"); } CallStackCurrent++; // Add this call graph to the tree view. FCallStack CallStack = FStreamInfo.GlobalInstance.CallStackArray[AllocationInfo.CallStackIndex]; // Split the tree into full and truncated callstacks. var RootNode = CallStack.bIsTruncated ? TruncatedNode : RegularNode; // Apply filter based on text representation of address. if (CallStack.RunFilters(FilterText, OwnerWindow.Options.ClassGroups, bFilterIn, OwnerWindow.SelectedMemoryPool)) { // Add call stack to proper part of graph. AddCallStackToGraph(RootNode, CallStack, AllocationInfo, ParentFunctionIndex, bInvertCallStacks); } } } Debug.WriteLine("FCallGraphTreeViewParser.ParseSnapshot - Sorting call graph tree for " + OwnerWindow.CurrentFilename); // Sort the nodes before adding them to the tree (sorting when in the tree is slow!). SortNodes(TruncatedNode, bShouldSortBySize); SortNodes(RegularNode, bShouldSortBySize); Debug.WriteLine("FCallGraphTreeViewParser.ParseSnapshot - Populating call graph tree for " + OwnerWindow.CurrentFilename); // Clear out existing nodes and add two root nodes. One for regular call stacks and one for truncated ones. CallGraphTreeView.Nodes.Clear(); CallGraphTreeView.Tag = new FCallGraphTreeViewTag(); AddRootTreeNode(TruncatedNode, CallGraphTreeView); AddRootTreeNode(RegularNode, CallGraphTreeView); CallGraphTreeView.BeforeExpand -= HandlePreExpandTreeNode; CallGraphTreeView.BeforeExpand += HandlePreExpandTreeNode; CallGraphTreeView.EndUpdate(); OwnerWindow.ToolStripProgressBar.Visible = false; }
/* * For debugging: dump the contents of an AllocRecord array. * * The array starts with the oldest known allocation and ends with * the most recent allocation. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unused") private static void dumpRecords(AllocationInfo[] records) private static void dumpRecords(AllocationInfo[] records) { Console.WriteLine("Found " + records.Length + " records:"); foreach (AllocationInfo rec in records) { Console.WriteLine("tid=" + rec.threadId + " " + rec.allocatedClass + " (" + rec.size + " bytes)"); foreach (StackTraceElement ste in rec.stackTrace) { if (ste.nativeMethod) { Console.WriteLine(" " + ste.className + "." + ste.methodName + " (Native method)"); } else { Console.WriteLine(" " + ste.className + "." + ste.methodName + " (" + ste.fileName + ":" + ste.lineNumber + ")"); } } } }
public override AllocationInfo ReAllocate(uint newSize, AllocationInfo existingAllocation) { throw new NotSupportedException(); }
public override unsafe bool TryAllocate(void* requestedAddress, uint size, out AllocationInfo? allocation) { throw new NotSupportedException(); }
private void EmitBlock(int blockIndex, LowMethod <X64Register> method, AllocationInfo <X64Register> allocation, CompiledMethod highMethod) { var block = method.Blocks[blockIndex]; var emitter = _peWriter.Emitter; // If this is the first block, save callee-saved registers and allocate shadow space for called methods // TODO: The shadow space could be reserved by the register allocator instead, once it supports the stack if (blockIndex == 0) { EmitRegisterSave(emitter, method); } foreach (var inst in block.Instructions) { switch (inst.Op) { case LowOp.LoadInt: { var destLocation = allocation.Get(inst.Dest).location; if (inst.Data == 0) { // "xor reg, reg" is the preferred way to zero a register on x64. This optimization // is not done by the peephole optimizer because it would break the SSA form. emitter.EmitGeneralBinaryOp(BinaryOp.BitwiseXor, destLocation, destLocation, 4); } else { emitter.EmitLoad(destLocation, inst.Data); } break; } case LowOp.Move: { var(sourceLocation, _) = allocation.Get(inst.Left); var(destLocation, destLocalIndex) = allocation.Get(inst.Dest); var destLocal = method.Locals[destLocalIndex]; // Move booleans always as 4 byte values so that we don't need to care about zero extension var operandSize = destLocal.Type.Equals(SimpleType.Bool) ? 4 : destLocal.Type.SizeInBytes; if (sourceLocation != destLocation) { emitter.EmitMov(destLocation, sourceLocation, operandSize); } break; } case LowOp.Swap: emitter.EmitExchange(allocation.Get(inst.Left).location, allocation.Get(inst.Right).location); break; case LowOp.IntegerAdd: EmitIntegerBinaryOp(BinaryOp.Add, in inst, method, allocation); break; case LowOp.IntegerSubtract: EmitIntegerBinaryOp(BinaryOp.Subtract, in inst, method, allocation); break; case LowOp.IntegerMultiply: EmitIntegerBinaryOp(BinaryOp.Multiply, in inst, method, allocation); break; case LowOp.IntegerDivide: case LowOp.IntegerModulo: { // The dividend is already guaranteed to be in RAX, and RDX is reserved. // We must sign-extend RAX to RDX and then emit the division instruction. // The desired result is either in RAX (divide) or RDX (modulo). var(leftLocation, leftLocalIndex) = allocation.Get(inst.Left); var(rightLocation, _) = allocation.Get(inst.Right); var operandSize = method.Locals[leftLocalIndex].Type.SizeInBytes; Debug.Assert(leftLocation.Register == X64Register.Rax); Debug.Assert(allocation.Get(inst.Dest).location.Register == X64Register.Rax || allocation.Get(inst.Dest).location.Register == X64Register.Rdx); emitter.EmitExtendRaxToRdx(operandSize); emitter.EmitSignedDivide(rightLocation, operandSize); break; } case LowOp.IntegerNegate: EmitIntegerUnaryOp(UnaryOp.Negate, in inst, method, allocation); break; case LowOp.BitwiseNot: EmitIntegerUnaryOp(UnaryOp.Not, in inst, method, allocation); break; case LowOp.BitwiseAnd: EmitIntegerBinaryOp(BinaryOp.BitwiseAnd, in inst, method, allocation); break; case LowOp.BitwiseOr: EmitIntegerBinaryOp(BinaryOp.BitwiseOr, in inst, method, allocation); break; case LowOp.BitwiseXor: EmitIntegerBinaryOp(BinaryOp.BitwiseXor, in inst, method, allocation); break; case LowOp.ShiftLeft: EmitShift(ShiftType.Left, in inst, method, allocation); break; case LowOp.ShiftArithmeticRight: EmitShift(ShiftType.ArithmeticRight, in inst, method, allocation); break; case LowOp.Compare: { // TODO: Can the left and right operands have different sizes? var(leftLocation, leftLocalIndex) = allocation.Get(inst.Left); var leftLocal = method.Locals[leftLocalIndex]; var operandSize = leftLocal.Type.Equals(SimpleType.Bool) ? 4 : leftLocal.Type.SizeInBytes; if (inst.Right == -1) { // Comparison with a constant emitter.EmitCmpWithImmediate(leftLocation, (int)inst.Data, operandSize); } else { // Comparison with another local emitter.EmitCmp(leftLocation, allocation.Get(inst.Right).location, operandSize); } break; } case LowOp.Test: { var srcDestLocation = allocation.Get(inst.Left).location; emitter.EmitTest(srcDestLocation, srcDestLocation); break; } case LowOp.SetIfEqual: EmitConditionalSet(X64Condition.Equal, allocation.Get(inst.Dest).location); break; case LowOp.SetIfNotEqual: EmitConditionalSet(X64Condition.NotEqual, allocation.Get(inst.Dest).location); break; case LowOp.SetIfLess: EmitConditionalSet(X64Condition.Less, allocation.Get(inst.Dest).location); break; case LowOp.SetIfLessOrEqual: EmitConditionalSet(X64Condition.LessOrEqual, allocation.Get(inst.Dest).location); break; case LowOp.SetIfGreater: EmitConditionalSet(X64Condition.Greater, allocation.Get(inst.Dest).location); break; case LowOp.SetIfGreaterOrEqual: EmitConditionalSet(X64Condition.GreaterOrEqual, allocation.Get(inst.Dest).location); break; case LowOp.Call: { var calleeName = highMethod.CallInfos[inst.Left].CalleeFullName; if (_peWriter.TryGetMethodOffset((int)inst.Data, out var knownOffset)) { // If the method offset is already known, emit a complete call emitter.EmitCall(knownOffset, calleeName); } else { // Otherwise, the offset must be fixed up later emitter.EmitCallWithFixup((int)inst.Data, calleeName, out var fixup); _peWriter.AddCallFixup(fixup); } break; } case LowOp.CallImported: { var calleeName = highMethod.CallInfos[inst.Left].CalleeFullName; emitter.EmitCallIndirectWithFixup((int)inst.Data, calleeName, out var fixup); _peWriter.AddCallFixup(fixup); break; } case LowOp.Jump: { // Do not emit a jump for a simple fallthrough if (inst.Dest == blockIndex + 1) { return; } // Don't bother creating a fixup for a backward branch where the destination is already known if (inst.Dest <= blockIndex) { emitter.EmitJmp(inst.Dest, _blockPositions[inst.Dest]); } else { emitter.EmitJmpWithFixup(inst.Dest, out var fixup); _fixupsForMethod.Add(fixup); } break; } case LowOp.JumpIfEqual: EmitConditionalJump(X64Condition.Equal, inst.Dest, blockIndex); break; case LowOp.JumpIfNotEqual: EmitConditionalJump(X64Condition.NotEqual, inst.Dest, blockIndex); break; case LowOp.JumpIfLess: EmitConditionalJump(X64Condition.Less, inst.Dest, blockIndex); break; case LowOp.JumpIfLessOrEqual: EmitConditionalJump(X64Condition.LessOrEqual, inst.Dest, blockIndex); break; case LowOp.JumpIfGreater: EmitConditionalJump(X64Condition.Greater, inst.Dest, blockIndex); break; case LowOp.JumpIfGreaterOrEqual: EmitConditionalJump(X64Condition.GreaterOrEqual, inst.Dest, blockIndex); break; case LowOp.Return: EmitReturn(emitter, method); return; case LowOp.Nop: break; default: throw new NotImplementedException("Unimplemented LIR opcode: " + inst.Op); } } }
public static void ParseSnapshot(ListViewEx ExclusiveListView, List <FCallStackAllocationInfo> CallStackList, bool bShouldSortBySize, string FilterText) { const int MaximumEntries = 400; // Progress bar. long ProgressInterval = MaximumEntries / 20; long NextProgressUpdate = ProgressInterval; int CallStackCurrent = 0; OwnerWindow.ToolStripProgressBar.Value = 0; OwnerWindow.ToolStripProgressBar.Visible = true; OwnerWindow.UpdateStatus("Updating exclusive list view for " + OwnerWindow.CurrentFilename); ExclusiveListView.BeginUpdate(); ExclusiveListView.ListViewItemSorter = null; // clear this to avoid a Sort for each call to Add bool bFilterIn = OwnerWindow.IsFilteringIn(); using (FScopedLogTimer ParseTiming = new FScopedLogTimer("FExclusiveListViewParser.ParseSnapshot")) { var FilteredCallstackList = new List <FCallStackAllocationInfo>(CallStackList.Count); foreach (var AllocationInfo in CallStackList) { var FilteredAllocationInfo = AllocationInfo.GetAllocationInfoForTags(OwnerWindow.GetTagsFilter(), bFilterIn); if (FilteredAllocationInfo.TotalCount != 0) { FilteredCallstackList.Add(FilteredAllocationInfo); } } // Sort based on passed in metric. if (bShouldSortBySize) { FilteredCallstackList.Sort(CompareAbsSize); } else { FilteredCallstackList.Sort(CompareCount); } // Figure out total size and count for percentages. long TotalSize = 0; long TotalCount = 0; foreach (FCallStackAllocationInfo AllocationInfo in FilteredCallstackList) { // Apply optional filter. if (FStreamInfo.GlobalInstance.CallStackArray[AllocationInfo.CallStackIndex].RunFilters(FilterText, OwnerWindow.Options.ClassGroups, bFilterIn, OwnerWindow.SelectedMemoryPool)) { TotalSize += AllocationInfo.TotalSize; TotalCount += AllocationInfo.TotalCount; } } // Clear out existing entries and add top 400. ExclusiveListView.Items.Clear(); for (int CallStackIndex = 0; CallStackIndex < FilteredCallstackList.Count && ExclusiveListView.Items.Count <= MaximumEntries; CallStackIndex++) { // Update progress bar. if (CallStackCurrent >= NextProgressUpdate) { OwnerWindow.ToolStripProgressBar.PerformStep(); NextProgressUpdate += ProgressInterval; Debug.WriteLine("FExclusiveListViewParser.ParseSnapshot " + OwnerWindow.ToolStripProgressBar.Value + "/20"); } CallStackCurrent++; FCallStackAllocationInfo AllocationInfo = FilteredCallstackList[CallStackIndex]; // Apply optional filter. FCallStack CallStack = FStreamInfo.GlobalInstance.CallStackArray[AllocationInfo.CallStackIndex]; if (CallStack.RunFilters(FilterText, OwnerWindow.Options.ClassGroups, bFilterIn, OwnerWindow.SelectedMemoryPool)) { string FunctionName = ""; int FirstStackFrameIndex; if (OwnerWindow.ContainersSplitButton.Text == " Show Containers") { FirstStackFrameIndex = CallStack.AddressIndices.Count - 1; } else { FirstStackFrameIndex = CallStack.FirstNonContainer; } do { FCallStackAddress Address = FStreamInfo.GlobalInstance.CallStackAddressArray[CallStack.AddressIndices[FirstStackFrameIndex]]; FunctionName = FStreamInfo.GlobalInstance.NameArray[Address.FunctionIndex]; FirstStackFrameIndex--; }while(UnhelpfulCallSites.Contains(FunctionName) && FirstStackFrameIndex > 0); var AllocationSize = AllocationInfo.TotalSize; var AllocationCount = AllocationInfo.TotalCount; string SizeInKByte = String.Format("{0:0}", ( float )AllocationSize / 1024).PadLeft(10, ' '); string SizePercent = String.Format("{0:0.00}", ( float )AllocationSize / TotalSize * 100).PadLeft(10, ' '); string Count = String.Format("{0:0}", AllocationCount).PadLeft(10, ' '); string CountPercent = String.Format("{0:0.00}", ( float )AllocationCount / TotalCount * 100).PadLeft(10, ' '); string GroupName = (CallStack.Group != null) ? CallStack.Group.Name : "Ungrouped"; string[] Row = new string[] { SizeInKByte, SizePercent, Count, CountPercent, GroupName, FunctionName }; ListViewItem Item = new ListViewItem(Row); Item.Tag = AllocationInfo; ExclusiveListView.Items.Add(Item); } } } var ColumnSorter = new MainWindow.FColumnSorter(); ColumnSorter.ColumnSortModeAscending = false; ColumnSorter.ColumnToSortBy = 0; ExclusiveListView.ListViewItemSorter = ColumnSorter; // Assignment automatically calls Sort ExclusiveListView.SetSortArrow(ColumnSorter.ColumnToSortBy, ColumnSorter.ColumnSortModeAscending); ExclusiveListView.EndUpdate(); OwnerWindow.ToolStripProgressBar.Visible = false; }
public PagerState(AbstractPager pager, long prefetchSegmentSize, long prefetchResetThreshold, AllocationInfo allocationInfo = null) { _pager = pager; #if DEBUG_PAGER_STATE Instances[this] = Environment.StackTrace; #endif long sizeInBytes = 0; if (allocationInfo != null) { this.AllocationInfos = new[] { allocationInfo }; this.MapBase = allocationInfo.BaseAddress; this.File = allocationInfo.MappedFile; sizeInBytes = allocationInfo.Size; } else { this.AllocationInfos = new AllocationInfo[] { }; this.MapBase = null; this.File = null; } this._segmentShift = Bits.MostSignificantBit(prefetchSegmentSize); this._prefetchSegmentSize = 1 << this._segmentShift; this._prefetchResetThreshold = (int)((float)prefetchResetThreshold / this._prefetchSegmentSize); Debug.Assert((_prefetchSegmentSize - 1) >> this._segmentShift == 0); Debug.Assert(_prefetchSegmentSize >> this._segmentShift == 1); long numberOfAllocatedSegments = (sizeInBytes / _prefetchSegmentSize) + 1; this._prefetchTable = new byte[(numberOfAllocatedSegments / 2) + 1]; }
public JsonResult GetRoomScheduleByDepartment(string DeptCode) { List <RoomAllocation> allocations = new List <RoomAllocation>(); string roomNo; newDatabaseGateway.Command.CommandText = "SELECT COURSE.CourseCode, CourseName, RoomNo, Day, FromTime, ToTime " + "FROM COURSE FULL OUTER JOIN ROOM_SCHEDULE ON COURSE.CourseCode = ROOM_SCHEDULE.CourseCode " + "WHERE DeptCode = '" + DeptCode + "' AND (Valid = 'True' OR Valid is NULL);"; newDatabaseGateway.Connection.Open(); SqlDataReader reader = newDatabaseGateway.Command.ExecuteReader(); while (reader.Read()) { RoomAllocation allocation = new RoomAllocation(); allocation.CourseCode = reader["CourseCode"].ToString(); allocation.CourseName = reader["CourseName"].ToString(); allocation.RoomNo = reader["RoomNo"].ToString(); allocation.Day = reader["Day"].ToString(); allocation.FromTime = reader["FromTime"].ToString(); allocation.ToTime = reader["ToTime"].ToString(); allocations.Add(allocation); } newDatabaseGateway.Connection.Close(); string CourseCode = ""; List <AllocationInfo> allocationList = new List <AllocationInfo>(); AllocationInfo allocationInfo = new AllocationInfo(); foreach (RoomAllocation roomAllocation in allocations) { if (CourseCode != roomAllocation.CourseCode) { CourseCode = roomAllocation.CourseCode; if (allocationInfo.CourseCode != null) { if (allocationInfo.CourseSchedule == null && allocationInfo.CourseCode != null && allocationInfo.CourseName != null) { allocationInfo.CourseSchedule = "Not Schedule Yet"; } if (allocationInfo.CourseCode != null && allocationInfo.CourseName != null && allocationInfo.CourseSchedule != null) { allocationList.Add(allocationInfo); } allocationInfo = new AllocationInfo(); } allocationInfo.CourseCode = roomAllocation.CourseCode; allocationInfo.CourseName = roomAllocation.CourseName; if (roomAllocation.RoomNo != "") { allocationInfo.CourseSchedule = "R.No:" + roomAllocation.RoomNo + "," + roomAllocation.Day + "," + roomAllocation.FromTime + "-" + roomAllocation.ToTime; } } else { allocationInfo.CourseSchedule += "\n" + "R.No:" + roomAllocation.RoomNo + "," + roomAllocation.Day + "," + roomAllocation.FromTime + "-" + roomAllocation.ToTime; } } if (allocationInfo.CourseSchedule == null && allocationInfo.CourseCode != null && allocationInfo.CourseName != null) { allocationInfo.CourseSchedule = "Not Schedule Yet"; } if (allocationInfo.CourseCode != null && allocationInfo.CourseName != null && allocationInfo.CourseSchedule != null) { allocationList.Add(allocationInfo); } return(Json(allocationList)); }
public abstract AllocationInfo ReAllocate(uint newSize, AllocationInfo existingAllocation);
public static void ParseSnapshot(List <FCallStackAllocationInfo> CallStackList, string FilterText) { // Progress bar long ProgressInterval = CallStackList.Count / 20; long NextProgressUpdate = ProgressInterval; int CallStackCurrent = 0; OwnerWindow.ToolStripProgressBar.Value = 0; OwnerWindow.ToolStripProgressBar.Visible = true; OwnerWindow.UpdateStatus("Updating histogram view for " + OwnerWindow.CurrentFilename); List <ClassGroup> CallStackGroups = OwnerWindow.Options.ClassGroups; List <FHistogramBar>[] Bars = new List <FHistogramBar> [NUM_MEMORY_BANKS]; for (int BankIndex = 0; BankIndex < Bars.Length; BankIndex++) { Bars[BankIndex] = new List <FHistogramBar>(); // The first bar in each column is for callstacks unmatched by any pattern. Bars[BankIndex].Add(new FHistogramBar("Other", Color.White)); // Add all groups to all memory bank columns. foreach (ClassGroup CallStackGroup in CallStackGroups) { var Bar = new FHistogramBar(CallStackGroup); Bar.BeginBatchAddition(); Bars[BankIndex].Add(Bar); } } using (FScopedLogTimer ParseTiming = new FScopedLogTimer("HistogramParser.ParseSnapshot")) { long Size = 0; int Count = 0; bool bFilterIn = OwnerWindow.IsFilteringIn(); var FilteredCallstackList = new List <FCallStackAllocationInfo>(CallStackList.Count); foreach (var AllocationInfo in CallStackList) { var FilteredAllocationInfo = AllocationInfo.GetAllocationInfoForTags(OwnerWindow.GetTagsFilter(), bFilterIn); if (FilteredAllocationInfo.TotalCount != 0) { FilteredCallstackList.Add(FilteredAllocationInfo); } } foreach (FCallStackAllocationInfo AllocationInfo in FilteredCallstackList) { // Update progress bar. if (CallStackCurrent >= NextProgressUpdate) { OwnerWindow.ToolStripProgressBar.PerformStep(); NextProgressUpdate += ProgressInterval; Debug.WriteLine("FHistogramParser.ParseSnapshot " + OwnerWindow.ToolStripProgressBar.Value + "/20"); } CallStackCurrent++; FCallStack OriginalCallStack = FStreamInfo.GlobalInstance.CallStackArray[AllocationInfo.CallStackIndex]; if (OriginalCallStack.RunFilters(FilterText, CallStackGroups, bFilterIn, OwnerWindow.SelectedMemoryPool)) { bool bFound = false; int Column = FMemoryPoolInfo.GetMemoryPoolHistogramColumn(OriginalCallStack.MemoryPool); if (Column == -1) { // If the callstack is in multiple pools, just put it in the first bank. // The user has already been warned about multi-pool callstacks. Column = 0; } for (int GroupIndex = 0; GroupIndex < CallStackGroups.Count; GroupIndex++) { foreach (CallStackPattern CallStackPatternIt in CallStackGroups[GroupIndex].CallStackPatterns) { if (CallStackPatternIt.ContainsCallStack(FStreamInfo.GlobalInstance.CallStackArray[AllocationInfo.CallStackIndex])) { Bars[Column][GroupIndex + 1].AddAllocation(AllocationInfo); bFound = true; goto HackyBreakAll; } } } HackyBreakAll: if (!bFound) { // No pattern matched this callstack, so add it to the Other bar Bars[Column][0].AddAllocation(AllocationInfo); } } Size += AllocationInfo.TotalSize; Count += AllocationInfo.TotalCount; } } // End the update batch and allow things to sort for (int BankIndex = 0; BankIndex < Bars.Length; BankIndex++) { foreach (ClassGroup CallStackGroup in CallStackGroups) { foreach (var Bar in Bars[BankIndex]) { Bar.EndBatchAddition(); } } } OwnerWindow.ToolStripProgressBar.Visible = false; HistogramBars = Bars; // Select first valid histogram bar. SelectFirstValidHistogramBar(); }
public abstract void Free(AllocationInfo allocation);