示例#1
0
        public void Pad()
        {
            try
            {
                UpdateFromConfig();

                long curMem = GC.GetTotalMemory(false);
                Log.buf.Append("Pad started, memory = ");
                Log.buf.Append((curMem / 1024));
                Log.buf.AppendLine(" KB");
                //Log.Flush();

                head8  = null;
                head16 = null;
                head24 = null;
                for (int i = 0; i < heads.Length; i++)
                {
                    heads[i] = null;
                }

                GC.Collect();
                curMem = GC.GetTotalMemory(false);
                Log.buf.Append("After disard and collect, memory = ");
                Log.buf.Append((curMem / 1024));
                Log.buf.AppendLine(" KB");
                //Log.Flush();

                // Do the small sizes with custom classes
                Pad8();
                Pad16();
                Pad24();

                // Do the rest of the sizes with arrays of object
                for (int i = 3; i < lengths.Length; i++)
                {
                    PadArray(i);
                }

                curMem = GC.GetTotalMemory(false);
                Log.buf.Append("After padding, memory = ");
                Log.buf.Append((curMem / 1024));
                Log.buf.AppendLine(" KB");
                //Log.Flush();

                GC.Collect();
                curMem = GC.GetTotalMemory(false);
                Log.buf.Append("After final collect, memory = ");
                Log.buf.Append((curMem / 1024));
                Log.buf.AppendLine(" KB");
                //Log.Flush();
            }
            catch (Exception e)
            {
                Log.buf.AppendLine(e.ToString());
            }
            Log.Flush();
        }
示例#2
0
        void Pad8()
        {
            long count = counts[0];

            Log.buf.Append("Pad(8): ");
            Log.buf.Append(count);
            Log.buf.AppendLine("");
            //Log.Flush();

            long  lastMem = GC.GetTotalMemory(false);
            Item8 temp    = null;
            Item8 test;

            while (count > 0)
            {
                // Allocate a block
                test = new Item8();

                long curMem = GC.GetTotalMemory(false);
                if (curMem == lastMem + 4096)
                {
                    // Add the block to the keep list
                    test.next = head8;
                    head8     = test;
                    count--;
                }
                else
                {
                    // Store the block in the temp list
                    test.next = temp;
                    temp      = test;
                }

                lastMem = curMem;
            }
        }