Exemplo n.º 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();
        }
Exemplo n.º 2
0
        void Pad24()
        {
            long count = counts[2];

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

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

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

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

                lastMem = curMem;
            }
        }