主頁 > 企業開發 > C#應用程式中沒有釋放記憶體

C#應用程式中沒有釋放記憶體

2022-01-25 20:00:34 企業開發

我有一個將 Ebcdic 轉換為 Ascii 的 C# 程式。程式的輸入檔案大小約為 250MB 到 300MB,當我通過放置單個檔案進行處理時,在共享路徑中檔案處理正在發生沒有任何問題,但是當輸入檔案位置中的檔案超過 1 個時,當第二個檔案處理到 50% 時,我得到System.OutOfMemoryException,我粘貼了示例代碼,我使用垃圾收集(處理單個檔案后)來釋放記憶體。但它沒有按預期作業,同時我也將決議器物件設為空,然后嘗試垃圾收集但仍然得到同樣的錯誤。

using System;
using System.Text;
using System.IO;
using System.Linq;

namespace Ebcdic2Ascii
{
    class Program
    {
         static void Main(string[] args)
          {
             DirectoryInfo d = new DirectoryInfo(@"C:\SampleFiles\input\");
             FileInfo[] Files = d.GetFiles("*.dat");
             StreamWriter[] writer = new StreamWriter[Files.Count()];
             LineTemplate lineTemplate = new LineTemplate(73, "ReservationsData");
             lineTemplate.AddFieldTemplate(new FieldTemplate("RESERVATION-NUMBER", FieldType.String, 0, 11));
             lineTemplate.AddFieldTemplate(new FieldTemplate("CHECKIN-DATE", FieldType.DateString, 11, 6));
             lineTemplate.AddFieldTemplate(new FieldTemplate("CALC-NET-AMOUNT", FieldType.BinaryNum, 17, 4, 2));
             lineTemplate.AddFieldTemplate(new FieldTemplate("CUSTOMER-NAME", FieldType.String, 21, 30));
             lineTemplate.AddFieldTemplate(new FieldTemplate("RUNDATE", FieldType.DateStringMMDDYY, 51, 6));
             lineTemplate.AddFieldTemplate(new FieldTemplate("CURRENCY-CONV-RATE", FieldType.Packed, 57, 6, 6));
             lineTemplate.AddFieldTemplate(new FieldTemplate("US-DOLLAR-AMOUNT-DUE", FieldType.Packed, 63, 6, 2));
             lineTemplate.AddFieldTemplate(new FieldTemplate("DATE-OF-BIRTH", FieldType.PackedDate, 69, 4));
             int i = 0;
             foreach (FileInfo File in Files)
             {
                  EbcdicParser parser = new EbcdicParser(File.FullName, lineTemplate);
                  string Outputpath = "C:\\output\\"   File.Name   ".txt";
                  writer[i] = new StreamWriter(Outputpath);
                  foreach (ParsedLine line in parser.ParsedLines)
                  {
                        writer[i].WriteLine(line["RESERVATION-NUMBER"].ToString()   "\t"   line["CHECKIN-DATE"].ToString()   "\t"   line["CALC-NET-AMOUNT"].ToString()   "\t"   line["CALC-NET-AMOUNT"].ToString()   "\t"   line["CUSTOMER-NAME"].ToString()   "\t"   line["RUNDATE"].ToString()   "\t"   line["CURRENCY-CONV-RATE"].ToString()   "\t"   line["US-DOLLAR-AMOUNT-DUE"].ToString()   "\t"   line["DATE - OF - BIRTH"].ToString());
                  }
                  i = i 1;
        
                 GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                 GC.Collect();
                 GC.WaitForPendingFinalizers();
            }
        }
    }
}

決議器的代碼這也有垃圾收集方法

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Ebcdic2Ascii
{
    public class EbcdicParser
    {
       public ParsedLine[] Lines { get; private set; }

       public EbcdicParser()
       {
        //Empty constructor
       }

       public EbcdicParser(byte[] allBytes, LineTemplate lineTemplate)
      {
        double expectedRows = (double)allBytes.Length / lineTemplate.LineSize;
        Console.WriteLine("{0}: Parsing started", DateTime.Now);
        Console.WriteLine("{1}: Line count est {0:#,###.00}", expectedRows, DateTime.Now);

        this.Lines = this.ParseAllLines(lineTemplate, allBytes);

        //Collect garbage
        GC.Collect();
        GC.WaitForPendingFinalizers();
        Console.WriteLine("{1}: {0} line(s) have been parsed", this.Lines.Count(), DateTime.Now);
      }

       public EbcdicParser(string sourceFilePath, LineTemplate lineTemplate)
        : this(File.ReadAllBytes(sourceFilePath), lineTemplate)
      {
        //Constructor with the file path
      } 
     
      public ParsedLine[] ParseAllLines(LineTemplate lineTemplate, byte[] allBytes)
      {
        bool isSingleLine = false;
        this.ValidateInputParameters(lineTemplate, allBytes, isSingleLine);
        
        List<ParsedLine> parsedLines = new List<ParsedLine>();
        byte[] lineBytes = new byte[lineTemplate.LineSize];
        ParsedLine parsedLine;

        for (int i = 0; i < allBytes.Length; i  = lineTemplate.LineSize)
        {
            if (i % 1000 == 0)
            {
                //Print progress
                Console.Write(i   "\r");
            }
            Array.Copy(allBytes, i, lineBytes, 0, lineTemplate.LineSize);
            parsedLine = this.ParseSingleLine(lineTemplate, lineBytes);
            parsedLines.Add(parsedLine);
        }
        return parsedLines.ToArray();
     }
     public ParsedLine[] ParseAllLines(LineTemplate lineTemplate, string sourceFilePath)
     {
        return this.ParseAllLines(lineTemplate, File.ReadAllBytes(sourceFilePath));
     }
     public ParsedLine ParseSingleLine(LineTemplate lineTemplate, byte[] lineBytes)
     {
        bool isSingleLine = true;
        this.ValidateInputParameters(lineTemplate, lineBytes, isSingleLine);
        ParsedLine parsedLine = new ParsedLine(lineTemplate, lineBytes);
        return parsedLine;
     }
     private bool ValidateInputParameters(LineTemplate lineTemplate, byte[] allBytes, bool isSingleLine)
     {
        if (allBytes == null)
        {
            throw new ArgumentNullException("Ebcdic data is not provided");
        }
        if (lineTemplate == null)
        {
            throw new ArgumentNullException("Line template is not provided");
        }
        if (lineTemplate.FieldsCount == 0)
        {
            throw new Exception("Line template must contain at least one field");
        }
        if (allBytes.Length < lineTemplate.LineSize)
        {
            throw new Exception("Data length is shorter than the line size");
        }
        if (isSingleLine && allBytes.Length != lineTemplate.LineSize)
        {
            throw new Exception("Bytes count doesn't equal to line size");
        }
        double expectedRows = (double)allBytes.Length / lineTemplate.LineSize;
        if (expectedRows % 1 != 0) //Expected number of rows is not a whole number
        {
            throw new Exception("Expected number of rows is not a whole number. Check line template.");
        }
        return true;
    }

    public void CreateCsvFile(string outputFilePath, bool includeColumnNames, bool addQuotes)
    {
        if (this.Lines == null || this.Lines.Length == 0)
        {
            throw new Exception("No lines have been parsed"); 
        }
        ParserUtilities.ConvertLineArrayToCsv(this.Lines, outputFilePath, includeColumnNames, addQuotes);
    }
  }
   }

ParsedLine 類檔案

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ebcdic2Ascii
{
  public class ParsedLine
  {
    public LineTemplate Line_Template { get; private set; }
    public Dictionary<string, ParsedField> FieldDictionary 
      { get; private set; } //= new Dictionary<string, ParsedField>();
    public string this[string fieldName]
    {
        get
        {
            return this.FieldDictionary[fieldName].Value.Trim();
        }
    } 

    //Constructor
    public ParsedLine(LineTemplate lineTemplate, byte[] lineBytes)
    {
        this.Line_Template = lineTemplate;
        this.ParseLine(lineBytes, lineTemplate);
    }

    private void ParseLine(byte[] lineBytes, LineTemplate lineTemplate)
    {
        this.ValidateInputParameters(lineBytes, lineTemplate);

        foreach (var fieldTemplate in lineTemplate.FieldTemplateDictionary)
        {
            FieldDictionary.Add(fieldTemplate.Key, 
              new ParsedField(lineBytes, lineTemplate.FieldTemplateDictionary[fieldTemplate.Key]));
        }
    }

    private void ValidateInputParameters(byte[] lineBytes, LineTemplate template)
    {
        if (lineBytes == null) 
        {
            throw new ArgumentNullException("Line bytes required");
        }
        if (lineBytes.Length < template.LineSize)
        {
            throw new Exception(String.Format(
              "Bytes provided: {0}, line size: {1}", lineBytes.Length, template.LineSize));
        }
        if (template == null)
        {
            throw new ArgumentNullException("line template is required");
        }
        if (template.FieldsCount == 0)
        {
            throw new Exception("Field templates have not been defined in the line template");
        }
    }

    public string GetParsedFieldValuesCSV(bool addQuotes)
    {
        StringBuilder sb = new StringBuilder();
        int count = 0;

        foreach (ParsedField parsedField in this.FieldDictionary.Values)
        {
            sb.Append(addQuotes ? "\"" : "");
            sb.Append(parsedField.Value);
            sb.Append(addQuotes ? "\"" : "");
            sb.Append(this.FieldDictionary.Count < count ? "," : "");
            count  ;
        }
        return sb.ToString();
    }
}
}

類 ParsedField

using System;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;

namespace Ebcdic2Ascii
{
public class ParsedField
{
    public FieldTemplate Field_Template { get; private set; }
    public string Value { get; private set; }
    public byte[] OriginalBytes { get; private set; }
    public string OriginalBytesInHex
    {
        get
        {
            return BitConverter.ToString(this.OriginalBytes);  
        }
    }
    public string OriginalBytesInDec
    {
        get
        {
            return ParserUtilities.ConvertBytesToDec(this.OriginalBytes);
        }
    }
    public bool ParsedSuccessfully { get; private set; }

    //Constructor
    public ParsedField(byte[] lineBytes, FieldTemplate fieldTemplate)
    {
        this.ParsedSuccessfully = true;
        this.Field_Template = fieldTemplate;
        this.Value = ParseField(lineBytes, fieldTemplate);
    }

    private string ParseField(byte[] lineBytes, FieldTemplate template)
    {
        if (lineBytes == null || lineBytes.Length == 0)
        {
            ParserUtilities.PrintError("Line bytes is null or empty");
            this.ParsedSuccessfully = false;
            return null;
        }
        if (lineBytes.Length < (template.StartPosition   template.FieldSize))
        {
            this.ParsedSuccessfully = false;
            throw new Exception(String.Format(
              "Field \"{0}\" length falls outside the line length", template.FieldName));
        }

        byte[] fieldBytes = new byte[template.FieldSize];
        Array.Copy(lineBytes, template.StartPosition, fieldBytes, 0, template.FieldSize);
        this.OriginalBytes = fieldBytes;

        if (this.Field_Template.Type == FieldType.AlphaNum)
        {
            return this.ConvertAlphaNumEbcdic(fieldBytes);
        }
        else if (this.Field_Template.Type == FieldType.Numeric)
        {
            return this.ConvertNumericEbcdic(fieldBytes, template.DecimalPlaces);
        }
        else if (this.Field_Template.Type == FieldType.Packed)
        {
            return this.Unpack(fieldBytes, template.DecimalPlaces);
        }
        else if (this.Field_Template.Type == FieldType.Binary)
        {
            return ConvertBinaryEbcdic(fieldBytes, template.DecimalPlaces);
        }
        else if (this.Field_Template.Type == FieldType.Date)
        {
            return ConvertDateStrEbcdic(fieldBytes);
        }
        else if (this.Field_Template.Type == FieldType.PackedDate)
        {
            return ConvertPackedDateStrEbcdic(fieldBytes);
        }
        else if (this.Field_Template.Type == FieldType.SourceBytesInHex)
        {
            return this.OriginalBytesInHex;
        }
        else if (this.Field_Template.Type == FieldType.SourceBytesInDec)
        {
            return this.OriginalBytesInDec;
        }
        else
        {
            this.ParsedSuccessfully = false;
            throw new Exception(String.Format(
              "Unable to parse field \"{0}\". Unknown field type: {1}", 
              template.FieldName, template.Type.ToString()));
        }
    }

    private string ConvertAlphaNumEbcdic(byte[] ebcdicBytes)
    {
        if (this.ByteArrayIsFullOf_0xFF(ebcdicBytes))
        {
            return "";
        }

        //Encoding asciiEnc = Encoding.ASCII;
        //Encoding ebcdicEnc = Encoding.GetEncoding("IBM037");
        //string result = Encoding.ASCII.GetString(Encoding.Convert(ebcdicEnc, asciiEnc, ebcdicBytes));

        //Thank you sx2008
        Encoding ebcdicEnc = Encoding.GetEncoding("IBM037");
        string result = ebcdicEnc.GetString(ebcdicBytes); // convert EBCDIC Bytes -> Unicode string
        return result;
    }

    private string ConvertNumericEbcdic(byte[] ebcdicBytes, int decimalPlaces)
    {
        string tempNumStr = this.ConvertAlphaNumEbcdic(ebcdicBytes).Trim();

        if (tempNumStr == null || tempNumStr.Length == 0)
        {
            return "";
        }

        if (Regex.IsMatch(tempNumStr, @"^\d $")) //Unsigned integer
        {
            string result = this.AdjustDecimalValues(Int64.Parse(tempNumStr), decimalPlaces);
            return result;
        }
        else if (Regex.IsMatch(tempNumStr, @"^\d [A-R{}]$")) //Signed integer
        {
            string lastChar = tempNumStr.Substring(tempNumStr.Length - 1);

            switch (lastChar)
            {
                case "{":
                    tempNumStr = tempNumStr.Replace("{", "0");
                    break;
                case "A":
                    tempNumStr = tempNumStr.Replace("A", "1");
                    break;
                case "B":
                    tempNumStr = tempNumStr.Replace("B", "2");
                    break;
                case "C":
                    tempNumStr = tempNumStr.Replace("C", "3");
                    break;
                case "D":
                    tempNumStr = tempNumStr.Replace("D", "4");
                    break;
                case "E":
                    tempNumStr = tempNumStr.Replace("E", "5");
                    break;
                case "F":
                    tempNumStr = tempNumStr.Replace("F", "6");
                    break;
                case "G":
                    tempNumStr = tempNumStr.Replace("G", "7");
                    break;
                case "H":
                    tempNumStr = tempNumStr.Replace("H", "8");
                    break;
                case "I":
                    tempNumStr = tempNumStr.Replace("I", "9");
                    break;
                case "}":
                    tempNumStr = "-"   tempNumStr.Replace("}", "0");//Fixed
                    break;
                case "J":
                    tempNumStr = "-"   tempNumStr.Replace("J", "1");
                    break;
                case "K":
                    tempNumStr = "-"   tempNumStr.Replace("K", "2");
                    break;
                case "L":
                    tempNumStr = "-"   tempNumStr.Replace("L", "3");
                    break;
                case "M":
                    tempNumStr = "-"   tempNumStr.Replace("M", "4");
                    break;
                case "N":
                    tempNumStr = "-"   tempNumStr.Replace("N", "5");
                    break;
                case "O":
                    tempNumStr = "-"   tempNumStr.Replace("O", "6");
                    break;
                case "P":
                    tempNumStr = "-"   tempNumStr.Replace("P", "7");
                    break;
                case "Q":
                    tempNumStr = "-"   tempNumStr.Replace("Q", "8");
                    break;
                case "R":
                    tempNumStr = "-"   tempNumStr.Replace("R", "9");
                    break;
            }

            string result = this.AdjustDecimalValues(Int64.Parse(tempNumStr), decimalPlaces);
            return result;
        }
        else
        {
            this.ParsedSuccessfully = false;
            return tempNumStr;
        }
    }

    private string ConvertBinaryEbcdic(byte[] ebcdicBytes, int decimalPlaces)
    {
        if (this.ByteArrayIsFullOf_0xFF(ebcdicBytes))
        {
            return "";
        }

        //BitConverter requires low order bytes goes first, followed by the higher order bytes. 
        //Bytes are stored in the file in the opposite order, thus need to reverse bytes
        Array.Reverse(ebcdicBytes);
        long tempNum;

        if (ebcdicBytes.Length == 2)
        {
            //If 2 bytes are provided -- assume it's a short
            tempNum = BitConverter.ToUInt16(ebcdicBytes, 0);
        }
        else if (ebcdicBytes.Length == 4)
        {
            //If 4 bytes are provided -- assume it's an int
            tempNum = BitConverter.ToInt32(ebcdicBytes, 0);
        }
        else
        {
            //Just in case
            throw new Exception(String.Format(
              "Incorrect number of bytes provided for a binary field: {1}", decimalPlaces));
        }

        string result = this.AdjustDecimalValues(tempNum, decimalPlaces);
        return result;
    }

    private string AdjustDecimalValues(long numericValue, int decimalPlaces)
    {
        if (decimalPlaces == 0)
        {
            return numericValue.ToString();
        }
        double result = numericValue / Math.Pow(10, decimalPlaces);
        return result.ToString();
    } 

    private string ConvertDateStrEbcdic(byte[] ebcdicBytes)
    {
        string dateStr = this.ConvertAlphaNumEbcdic(ebcdicBytes).Trim();
        string result = this.ConvertDateStr(dateStr);
        return result;
    }

    private string ConvertPackedDateStrEbcdic(byte[] ebcdicBytes)
    {
        string dateStr = this.Unpack(ebcdicBytes, 0);
        string result = this.ConvertDateStr(dateStr);
        return result;
    }

    private string ConvertDateStr(string dateStr)
    {
        dateStr = dateStr.Trim();

        if (dateStr.Trim() == "" || dateStr == "0" || 
              dateStr == "0000000" || dateStr == "9999999")
        {
            return "";
        }
        if (Regex.IsMatch(dateStr, @"^\d{3,5}$"))
        {
            dateStr = dateStr.PadLeft(6, '0');
        }

        Match match = Regex.Match(dateStr, @"^(?<Year>\d{3})(?<Month>\d{2})
        (?<Day>\d{2})$"); //E.g.: 0801232 = 1980-12-31; 1811231 = 2080-12-31

        if (match.Success)
        {
            int year = Int32.Parse(match.Groups["Year"].Value)   1900; //013 => 1913, 113 => 2013...
            int month = Int32.Parse(match.Groups["Month"].Value);
            int day = Int32.Parse(match.Groups["Day"].Value);

            try
            {
                DateTime tempDate = new DateTime(year, month, day);
                return tempDate.ToString("yyyy-MM-dd");
            }
            catch { }
        }

        if (Regex.IsMatch(dateStr, @"^\d{6}$"))
        {
            DateTime tempDate;
            if (DateTime.TryParseExact(dateStr, "yyMMdd", 
                 CultureInfo.InvariantCulture, DateTimeStyles.None, out tempDate))
            {
                return tempDate.ToString("yyyy-MM-dd");
            }
        }

        this.ParsedSuccessfully = false;
        return dateStr;
    } 

    private string Unpack(byte[] ebcdicBytes, int decimalPlaces)
    {
        if (ByteArrayIsFullOf_0xFF(ebcdicBytes))
        {
            return "";
        }

        long lo = 0;
        long mid = 0;
        long hi = 0;
        bool isNegative;

        // this nybble stores only the sign, not a digit.  
        // "C" hex is positive, "D" hex is negative, and "F" hex is unsigned. 
        switch (Nibble(ebcdicBytes, 0))
        {
            case 0x0D:
                isNegative = true;
                break;
            case 0x0F:
            case 0x0C:
                isNegative = false;
                break;
            default:
                //throw new Exception("Bad sign nibble");
                this.ParsedSuccessfully = false;
                return this.ConvertAlphaNumEbcdic(ebcdicBytes);
        }
        long intermediate;
        long carry;
        long digit;
        for (int j = ebcdicBytes.Length * 2 - 1; j > 0; j--)
        {
            // multiply by 10
            intermediate = lo * 10;
            lo = intermediate & 0xffffffff;
            carry = intermediate >> 32;
            intermediate = mid * 10   carry;
            mid = intermediate & 0xffffffff;
            carry = intermediate >> 32;
            intermediate = hi * 10   carry;
            hi = intermediate & 0xffffffff;
            carry = intermediate >> 32;
            // By limiting input length to 14, we ensure overflow will never occur

            digit = Nibble(ebcdicBytes, j);
            if (digit > 9)
            {
                //throw new Exception("Bad digit");
                this.ParsedSuccessfully = false;
                return this.ConvertAlphaNumEbcdic(ebcdicBytes);
            }
            intermediate = lo   digit;
            lo = intermediate & 0xffffffff;
            carry = intermediate >> 32;
            if (carry > 0)
            {
                intermediate = mid   carry;
                mid = intermediate & 0xffffffff;
                carry = intermediate >> 32;
                if (carry > 0)
                {
                    intermediate = hi   carry;
                    hi = intermediate & 0xffffffff;
                    carry = intermediate >> 32;
                    // carry should never be non-zero. Back up with validation
                }
            }
        }

        decimal result = new Decimal((int)lo, (int)mid, (int)hi, isNegative, (byte)decimalPlaces);
        return result.ToString();
    }

    private int Nibble(byte[] ebcdicBytes, int nibbleNo)
    {
        int b = ebcdicBytes[ebcdicBytes.Length - 1 - nibbleNo / 2];
        return (nibbleNo % 2 == 0) ? (b & 0x0000000F) : (b >> 4);
    }

    private bool ByteArrayIsFullOf_0xFF(byte[] ebcdicBytes)
    {
        if (ebcdicBytes == null || ebcdicBytes.Length == 0)
        {
            return false;
        }
        foreach (byte b in ebcdicBytes)
        {
            if (b != 0xFF)
            {
                return false;
            }
        }
        return true;
    }
}
}

LineTemplate class,FieldTemplate class,ParserUtilities class are present in page Click C# 應用程式中沒有釋放記憶體

uj5u.com熱心網友回復:

這很可能System.OutOfMemoryException是因為您用完了檔案句柄,而不是實際記憶體。StreamWriter您正在為您處理的每個檔案創建一個新檔案而不對其進行處理。

請參閱System.OutOfMemoryException的檔案。它具體說:

盡管垃圾收集器能夠釋放分配給托管型別的記憶體,但它不管理分配給非托管資源的記憶體,例如作業系統句柄(包括檔案句柄、記憶體映射檔案、管道、注冊表項和等待句柄)和記憶體由 Windows API 呼叫或通過呼叫諸如 malloc 之類的記憶體分配函式直接分配的塊。消耗非托管資源的型別實作 IDisposable 介面。

如果您正在使用使用非托管資源的型別,則應確保在使用完畢后呼叫其 IDisposable.Dispose 方法。(某些型別還實作了與 Dispose 方法功能相同的 Close 方法。)有關詳細資訊,請參閱使用實作 IDisposable 的物件主題。

重要的是要注意垃圾收集器不會要求Dispose()您。

您必須writer[i].Dispose()在完成每個流的寫入后呼叫

uj5u.com熱心網友回復:

我同意 John Glenn 的觀點,嘗試使用單個 StreamWriter 將您的決議作業放入一個方法和 Enigmativity 的建議中。

static void Parse(.....)
{
    EbcdicParser parser = new EbcdicParser(File.FullName, lineTemplate);
    string Outputpath = "C:\\output\\"   File.Name   ".txt";
    using(var writer = new StreamWriter(Outputpath))
    {
        foreach (ParsedLine line in parser.ParsedLines)
        {
             .....
        }
    }
}

在范圍之外運行 GC。

int i = 0;
foreach (FileInfo File in Files)
{
    Parse(......);
    GC.Collect();
}

uj5u.com熱心網友回復:

您的垃圾收集呼叫沒有您想要的效果。在您的 foreach 回圈中,EbcdicParser parser仍然可以訪問,因為它在當前執行的函式的范圍內,因此不考慮進行垃圾回收。

同樣,在您的 EbcdicParser 中,位元組陣列仍然可以訪問,因此您的垃圾回收呼叫也不會清除它。

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/420772.html

標籤:

上一篇:如何觸發FlowLayoutPanel的滾動事件?

下一篇:C#到VB.net的轉換關于Selenium等待示例

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • IEEE1588PTP在數字化變電站時鐘同步方面的應用

    IEEE1588ptp在數字化變電站時鐘同步方面的應用 京準電子科技官微——ahjzsz 一、電力系統時間同步基本概況 隨著對IEC 61850標準研究的不斷深入,國內外學者提出基于IEC61850通信標準體系建設數字化變電站的發展思路。數字化變電站與常規變電站的顯著區別在于程序層傳統的電流/電壓互 ......

    uj5u.com 2020-09-10 03:51:52 more
  • HTTP request smuggling CL.TE

    CL.TE 簡介 前端通過Content-Length處理請求,通過反向代理或者負載均衡將請求轉發到后端,后端Transfer-Encoding優先級較高,以TE處理請求造成安全問題。 檢測 發送如下資料包 POST / HTTP/1.1 Host: ac391f7e1e9af821806e890 ......

    uj5u.com 2020-09-10 03:52:11 more
  • 網路滲透資料大全單——漏洞庫篇

    網路滲透資料大全單——漏洞庫篇漏洞庫 NVD ——美國國家漏洞庫 →http://nvd.nist.gov/。 CERT ——美國國家應急回應中心 →https://www.us-cert.gov/ OSVDB ——開源漏洞庫 →http://osvdb.org Bugtraq ——賽門鐵克 →ht ......

    uj5u.com 2020-09-10 03:52:15 more
  • 京準講述NTP時鐘服務器應用及原理

    京準講述NTP時鐘服務器應用及原理京準講述NTP時鐘服務器應用及原理 安徽京準電子科技官微——ahjzsz 北斗授時原理 授時是指接識訓通過某種方式獲得本地時間與北斗標準時間的鐘差,然后調整本地時鐘使時差控制在一定的精度范圍內。 衛星導航系統通常由三部分組成:導航授時衛星、地面檢測校正維護系統和用戶 ......

    uj5u.com 2020-09-10 03:52:25 more
  • 利用北斗衛星系統設計NTP網路時間服務器

    利用北斗衛星系統設計NTP網路時間服務器 利用北斗衛星系統設計NTP網路時間服務器 安徽京準電子科技官微——ahjzsz 概述 NTP網路時間服務器是一款支持NTP和SNTP網路時間同步協議,高精度、大容量、高品質的高科技時鐘產品。 NTP網路時間服務器設備采用冗余架構設計,高精度時鐘直接來源于北斗 ......

    uj5u.com 2020-09-10 03:52:35 more
  • 詳細解讀電力系統各種對時方式

    詳細解讀電力系統各種對時方式 詳細解讀電力系統各種對時方式 安徽京準電子科技官微——ahjzsz,更多資料請添加VX 衛星同步時鐘是我京準公司開發研制的應用衛星授時時技術的標準時間顯示和發送的裝置,該裝置以M國全球定位系統(GLOBAL POSITIONING SYSTEM,縮寫為GPS)或者我國北 ......

    uj5u.com 2020-09-10 03:52:45 more
  • 如何保證外包團隊接入企業內網安全

    不管企業規模的大小,只要企業想省錢,那么企業的某些服務就一定會采用外包的形式,然而看似美好又經濟的策略,其實也有不好的一面。下面我通過安全的角度來聊聊使用外包團的安全隱患問題。 先看看什么服務會使用外包的,最常見的就是話務/客服這種需要大量重復性、無技術性的服務,或者是一些銷售外包、特殊的職能外包等 ......

    uj5u.com 2020-09-10 03:52:57 more
  • PHP漏洞之【整型數字型SQL注入】

    0x01 什么是SQL注入 SQL是一種注入攻擊,通過前端帶入后端資料庫進行惡意的SQL陳述句查詢。 0x02 SQL整型注入原理 SQL注入一般發生在動態網站URL地址里,當然也會發生在其它地發,如登錄框等等也會存在注入,只要是和資料庫打交道的地方都有可能存在。 如這里http://192.168. ......

    uj5u.com 2020-09-10 03:55:40 more
  • [GXYCTF2019]禁止套娃

    git泄露獲取原始碼 使用GET傳參,引數為exp 經過三層過濾執行 第一層過濾偽協議,第二層過濾帶引數的函式,第三層過濾一些函式 preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp'] (?R)參考當前正則運算式,相當于匹配函式里的引數 因此傳遞 ......

    uj5u.com 2020-09-10 03:56:07 more
  • 等保2.0實施流程

    流程 結論 ......

    uj5u.com 2020-09-10 03:56:16 more
最新发布
  • 使用Django Rest framework搭建Blog

    在前面的Blog例子中我們使用的是GraphQL, 雖然GraphQL的使用處于上升趨勢,但是Rest API還是使用的更廣泛一些. 所以還是決定回到傳統的rest api framework上來, Django rest framework的官網上給了一個很好用的QuickStart, 我參考Qu ......

    uj5u.com 2023-04-20 08:17:54 more
  • 記錄-new Date() 我忍你很久了!

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 大家平時在開發的時候有沒被new Date()折磨過?就是它的諸多怪異的設定讓你每每用的時候,都可能不小心踩坑。造成程式意外出錯,卻一下子找不到問題出處,那叫一個煩透了…… 下面,我就列舉它的“四宗罪”及應用思考 可惡的四宗罪 1. Sa ......

    uj5u.com 2023-04-20 08:17:47 more
  • 使用Vue.js實作文字跑馬燈效果

    實作文字跑馬燈效果,首先用到 substring()截取 和 setInterval計時器 clearInterval()清除計時器 效果如下: 實作代碼如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta ......

    uj5u.com 2023-04-20 08:12:31 more
  • JavaScript 運算子

    JavaScript 運算子/運算子 在 JavaScript 中,有一些運算子可以使代碼更簡潔、易讀和高效。以下是一些常見的運算子: 1、可選鏈運算子(optional chaining operator) ?.是可選鏈運算子(optional chaining operator)。?. 可選鏈操 ......

    uj5u.com 2023-04-20 08:02:25 more
  • CSS—相對單位rem

    一、概述 rem是一個相對長度單位,它的單位長度取決于根標簽html的字體尺寸。rem即root em的意思,中文翻譯為根em。瀏覽器的文本尺寸一般默認為16px,即默認情況下: 1rem = 16px rem布局原理:根據CSS媒體查詢功能,更改根標簽的字體尺寸,實作rem單位隨螢屏尺寸的變化,如 ......

    uj5u.com 2023-04-20 08:02:21 more
  • 我的第一個NPM包:panghu-planebattle-esm(胖虎飛機大戰)使用說明

    好家伙,我的包終于開發完啦 歡迎使用胖虎的飛機大戰包!! 為你的主頁添加色彩 這是一個有趣的網頁小游戲包,使用canvas和js開發 使用ES6模塊化開發 效果圖如下: (覺得圖片太sb的可以自己改) 代碼已開源!! Git: https://gitee.com/tang-and-han-dynas ......

    uj5u.com 2023-04-20 08:01:50 more
  • 如何在 vue3 中使用 jsx/tsx?

    我們都知道,通常情況下我們使用 vue 大多都是用的 SFC(Signle File Component)單檔案組件模式,即一個組件就是一個檔案,但其實 Vue 也是支持使用 JSX 來撰寫組件的。這里不討論 SFC 和 JSX 的好壞,這個仁者見仁智者見智。本篇文章旨在帶領大家快速了解和使用 Vu ......

    uj5u.com 2023-04-20 08:01:37 more
  • 【Vue2.x原始碼系列06】計算屬性computed原理

    本章目標:計算屬性是如何實作的?計算屬性快取原理以及洋蔥模型的應用?在初始化Vue實體時,我們會給每個計算屬性都創建一個對應watcher,我們稱之為計算屬性watcher ......

    uj5u.com 2023-04-20 08:01:31 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:01:10 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:00:32 more