GVKun编程网logo

Splunk 将第二个查询结果字段放入 Linux 主机的 Percentage Memory 的第一个查询中

3

对于想了解Splunk将第二个查询结果字段放入Linux主机的PercentageMemory的第一个查询中的读者,本文将提供新的信息,并且为您提供关于.NETMemoryissuesloading~

对于想了解Splunk 将第二个查询结果字段放入 Linux 主机的 Percentage Memory 的第一个查询中的读者,本文将提供新的信息,并且为您提供关于.NET Memory issues loading ~40 images, memory not reclaimed, potentially due to LOH fragmentation、ASP.NET – 如何在C#表上设置Cells-Width-Percentage、Attempted to read or write protected memory. This is often an indication that other memory is corrupt.、Clang 是否为 WebAssembly 的 memory.fill 和 memory.copy 提供内在函数?的有价值信息。

本文目录一览:

Splunk 将第二个查询结果字段放入 Linux 主机的 Percentage Memory 的第一个查询中

Splunk 将第二个查询结果字段放入 Linux 主机的 Percentage Memory 的第一个查询中

如何解决Splunk 将第二个查询结果字段放入 Linux 主机的 Percentage Memory 的第一个查询中

我是 Splunk 的新手。

我正在尝试拉取属于名为 Memory % 的特定组的 Linux 主机的 Database_hosts

如果我将其明确提供为 Memory %,我能够获得特定主机的 host="host01.example.com",但是,我希望针对多个主机运行此查询。

我可以从 Splunk 中的 Database_hosts 中提取属于 inputlookup cmdb_host.csv 组的多个主机。

现在,我可以从 inputlookup cmdb_host.csv 中提取主机,其中它包含 name 字段中的主机,但我不知道如何将第二个查询放入我的第一个查询中,即 sourcetype=top pctMEM=* host="host01.example.com">

虽然这两个查询都是独立工作的。

我的第一个查询。

sourcetype=top pctMEM=* host="host01" OR host="host02"
| multikv 
| dedup host
| rex field=pctMEM "(?<usage>\\d+)" 
| where usage> 40
| table  host pctMEM

运行结果

第二次查询

| inputlookup cmdb_host.csv
| search support_group="Database_hosts" NOT (fqdn IN("aP*","aw*",""))
| table name

运行结果:

如何将我的第二个查询输出字段 name 用于第一个查询 host= 字段。

任何帮助将不胜感激。

编辑:

刚刚尝试但没有运气:

sourcetype=top pctMEM=* host="[inputlookup cmdb_host.csv where support_group="Database_hosts" | table name] 
| multikv 
| dedup name
| rex field=pctMEM "(?<usage>\\d+)" 
| where usage>20
| table  name pctMEM

解决方法

你很亲近。如果您单独运行子搜索(方括号内的部分)并添加 | format,那么您将看到返回到主搜索的内容。它看起来像 ((name=host01) OR (name=host02))。将其与主要搜索相结合会产生:

sourcetype=top pctMEM=* host=((name=host01) OR (name=host02))
| multikv 
| dedup name
| rex field=pctMEM "(?<usage>\\d+)" 
| where usage>20
| table  name pctMEM

这行不通。可以通过在子搜索中将 name 重命名为 host 并让子搜索创建表达式来修复它。

sourcetype=top pctMEM=* [|inputlookup cmdb_host.csv where support_group="Database_hosts" 
  | return 100 host=name]
| multikv 
| dedup name
| rex field=pctMEM "(?<usage>\\d+)" 
| where usage>20
| table  name pctMEM

return 命令告诉 Splunk 最多返回 100 个结果并将 name 重命名为 host。它相当于 fields name | rename name as host | format

.NET Memory issues loading ~40 images, memory not reclaimed, potentially due to LOH fragmentation

.NET Memory issues loading ~40 images, memory not reclaimed, potentially due to LOH fragmentation

Well, this is my first foray into memory profiling a .NET app (CPU tuning I
have done) and I am hitting a bit of a wall here.

I have a view in my app which loads 40 images (max) per page, each running
about ~3MB. The max number of pages is 10. Seeing as I don’t want to keep 400
images or 1.2GB in memory at once, I set each image to null when the page is
changed.

Now, at first I thought that I must just have stale references to these
images. I downloaded ANTS profiler (great tool BTW) and ran a few tests. The
object lifetime graph tells me that I don’t have any references to these
images other than the single reference in the parent class (which is by
design, also confirmed by meticulously combing through my code):

The parent class SlideViewModelBase sticks around forever in a cache, but
the MacroImage property is set to null when the page is changed. I don’t see
any indication that these objects should be kept around longer than expected.

I next took a look at the large object heap and memory usage in general. After
looking at three pages of images I have 691.9MB of unmanaged memory allocated
and 442.3MB on the LOH. System.Byte[], which comes from my
System.Drawing.Bitmap to BitmapImage conversion is taking pretty much all
of the LOH space. Here is my conversion code:

public static BitmapSource ToBmpSrc( this Bitmap b ){    var bi = new BitmapImage();    var ms = new MemoryStream();    bi.CacheOption = BitmapCacheOption.OnLoad;    b.Save( ms,  ImageFormat.Bmp );    ms.Position = 0;    bi.BeginInit();    ms.Seek( 0, SeekOrigin.Begin );    bi.StreamSource = ms;    bi.EndInit();    return bi;}

I am having a hard time finding where all of that unmanaged memory is going. I
suspected the System.Drawing.Bitmap objects at first, but ANTS doesn’t show
them sticking around, and I also ran a test where I made absolutely sure that
all of them were disposed and it didn’t make a difference. So I haven’t yet
figured out where all of that unmanaged memory is coming from.

My two current theories are:

  1. LOH fragmentation. If I navigate away from the paged view and click a couple of buttons about half of the ~1.5GB is reclaimed. Still too much, but interesting nonetheless.
  2. Some weird WPF binding thing. We do use databinding to display these images and I am no expert in regards to the ins and outs of how these WPF controls work.

If anyone has any theories or profiling tips I would be extremely grateful as
(of course) we are on a tight deadline and I am scrambling a bit to get this
final part done and working. I think I’ve been spoiled by tracking down memory
leaks in C++ … who woulda’ thought?

If you need more info or would like me to try something else please ask. Sorry
about the wall-o-text here, I tried to keep it as concise as possible.

答案1

小编典典

This blog
post
appears to descibe what you are seeing, and the proposed solution was to
create an implementation of Stream that wraps another
stream.

The Dispose method of this wrapper class needs to release the wrapped stream,
so that it can be garbage collected. Once the BitmapImage is initialised with
this wrapper stream, the wrapper stream can be disposed, releasing the
underlying stream, and allowing the large byte array itself to be freed.

The BitmapImage keeps a reference to the source stream so it keeps the
MemoryStream object alive. Unfortunately, even though MemoryStream.Dispose
has been invoked, it doesn’t release the byte array that the memory stream
wraps. So, in this case, bitmap is referencing stream, which is referencing
buffer, which may be taking up a lot of space on the large object heap.
There isn’t a true memory leak; when there are no more references to bitmap,
all these objects will (eventually) be garbage collected. But since bitmap
has already made its own private copy of the image (for rendering), it seems
rather wasteful to have the now-unnecessary original copy of the bitmap
still in memory.

Also, what version of .NET are you using? Prior to .NET 3.5 SP1, there was a
known issue where a BitmapImage could cause a memory
leak. The workaround was to call
Freeze on the
BitmapImage.

ASP.NET – 如何在C#表上设置Cells-Width-Percentage

ASP.NET – 如何在C#表上设置Cells-Width-Percentage

大家好!我有一个System.Web.UI.WebControls.Table,单元格(控件)的宽度(默认为20%).我想改变这个百分比 – > 40%/ 20%/ 20%/ 10%/ 10%

我想要关注:

如何在此单元格(控件)上设置不同的宽度?

这是我的代码:

Table myTbl = new Table();
TableRow tRow1 = new TableRow();

    //Row1 Cells Controls

            TextBox txt11 = new TextBox();
            txt11.ID = "txtDest11";
            txt11.Height = 19;
           //txt11.Width = Unit.Percentage(40);

            TextBox txt12 = new TextBox();
            txt12.ID = "txtKmInCity12";
            txt12.Height = 19;

            TextBox txt13 = new TextBox();
            txt13.ID = "txtKmOutCity13";
            txt13.Height = 19;

            DateTimeControl dt11 = new DateTimeControl();
            dt11.DateOnly = true;
            dt11.ShowWeekNumber = true;
            dt11.LocaleId = 1026;

            DateTimeControl dt12 = new DateTimeControl();
            dt12.DateOnly = true;
            dt12.ShowWeekNumber = true;
            dt12.LocaleId = 1026;

            tRow1 = new TableRow();
            tRow1.Visible = true;

            TableCell tCellZero = new TableCell();
            tCellZero.Controls.Add(rowNo);
            tRow1.Cells.Add(tCellZero);

            TableCell tCellOne = new TableCell();
            tCellOne.Controls.Add(txt11);
            tRow1.Cells.Add(tCellOne);

            TableCell tCellTwo = new TableCell();
            tCellTwo.Controls.Add(dt11);
            tRow1.Cells.Add(tCellTwo);

            TableCell tCellThree = new TableCell();
            tCellThree.Controls.Add(dt12);
            tRow1.Cells.Add(tCellThree);

            TableCell tCellFour = new TableCell();
            tCellFour.Controls.Add(txt12);
            tRow1.Cells.Add(tCellFour);

            TableCell tCellFive = new TableCell();
            tCellFive.Controls.Add(txt13);
            tRow1.Cells.Add(tCellFive);

            myTbl.Rows.Add(tRow1);

结果:

解决方法

添加宽度到TableCell.用这个:

TableCell myTableCell = new TableCell();
myTableCell.Width = new Unit("25%");

要么

myTableCell.Style.Add("width","25%");

更新:

对于文本框:

TextBox txt11 = new TextBox();
txt11.ID = "txtDest11";
txt11.Height = 19;
txt11.Style.Add("width","100%");

对于TableCells:

TableCell tCellOne = new TableCell();
 tCellOne.Style.Add("width","40%");
 tCellOne.Controls.Add(txt11);
 tRow1.Cells.Add(tCellOne);

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source Error:

Line 37:         protected void Application_Start(Object sender, EventArgs e)
Line 38:         {
Line 39:             AppStartLogger.ResetLog();
Line 40:             AppStartLogger.WriteLine("Starting AspDotNetStorefront...");
Line 41: 

Source File: e:\Just\JustWeb\App_Code\Global.asax.cs    Line: 39

 

 

Symptoms
Accessing the site results in an "Attempted To Read Or Write Protected Memory" error.

Cause
There are 2 potential causes of this issue:

    1 - A site running a version of the ASPDNSF software older than 7.0.2.5 is attempting to run in a medium-trust hosting environment.

    2 - A site running a version of the ASPDNSF software older than 7.0.2.5 is running on a host that has just applied the .NET 3.5 SP1 upgrade to the servers.

NOTE: In both of these cases, the problem lies with the environment the software is running in, as configured by the host.  These are not flaws in the software, and are beyond our control.

Procedure
The best solution (regardless of which of the 2 causes above is creating your issue) is to upgrade to version 7.0.2.5 SP1 or higher of the ASPDNSF software.  Those later versions can run natively in medium-trust (thus avoiding issue #1) and work fine with the latest .NET service pack (which didn't even exist before then for us to test against). 

If upgrading is not an option at the moment, there are other workarounds for each possible cause.  Note that these are the ONLY workarounds.  We can provide no other advice than these steps:

Medium Trust:

    1 - First, have the host or server admin apply the Microsoft-created hotfix available at
http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=6003

    2 - Contact support and request a special medium-trust build of the software.  We will need a valid order number to provide that.

    3 - Move to a full-trust environment (this may mean switching hosts).

.NET 3.5 SP1 Patch:

    1 - Have the host roll back the changes on the server, or move your site to a server that has not had the patch applied.

 

https://support.aspdotnetstorefront.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=208

 

If you are using aspdotnetstorefront and are getting the following error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 

then please contact aspdotnetstorefront in regards to the error as you will have to upgrade your aspdotnetstorefront storefront application to version 7.0.2.5 SP1 or version 7.1.0.0 if the .NET 3.5 service pack is installed.

If you are not using aspdotnetstorefront and are getting this error, you will need to verify that you code works with the lates dotnet service packs for all versions. This error is usually remoting related, but not always.

Clang 是否为 WebAssembly 的 memory.fill 和 memory.copy 提供内在函数?

Clang 是否为 WebAssembly 的 memory.fill 和 memory.copy 提供内在函数?

如何解决Clang 是否为 WebAssembly 的 memory.fill 和 memory.copy 提供内在函数?

我正在用 C 语言开发 WebAssembly 模块,并一直在尝试利用 WebAssembly spec 中定义的 memory.fillmemory.copy 指令。

我知道 Clang (v11.1.0) 已经 supports other memory-related wasm intrinsics 喜欢 __builtin_wasm_memory_size__builtin_wasm_memory_grow,但是我一直很难确定它是否支持 {{1 }} 和 memory.fill

我对 Clang/LLVM 的内部工作并不十分熟悉,但似乎在几个地方 [1] [2] 中似乎暗示了对这些指令的引用(除非我误解了某些东西)。

我尝试使用 memory.copy__builtin_memcpy

  1. __builtin_memset

它可以编译,但是对 __attribute__((export_name("memcpy"))) void memcpy_test(void* mem_dst,void* mem_src) { __builtin_memcpy(mem_dst,mem_src,128); } __attribute__((export_name("memset"))) void memset_test(void* mem_src) { __builtin_memset(mem_src,128); } __builtin_memcpy 的调用被替换为程序集中的导入函数:

  1. __builtin_memset

在这一点上我有点卡住了,这些内在函数似乎还没有可用,但我对此并不乐观。

我真的很感激我能得到的任何帮助!

[快速说明:我目前对使用 emscripten 不感兴趣,因为我试图避免它附带的大量胶水代码。]

解决方法

但是对 __builtin_memcpy__builtin_memset 的调用被替换为程序集中的导入函数:

原因是这些指令不是核心 (MVP) WebAssembly 指令集的一部分,而是后来添加到 bulk-memory proposal 中。

需要明确选择这些后来的提案,因为存在您可能针对的给定 WebAssembly 引擎尚不支持它们的风险。当然,您可以检查 my support table on webassembly.org。

最后,如果您已选中此项,则可以通过 -mbulk-memory 标志在 Clang 中选择加入此功能。例如,启用此标志和优化

  1. clang temp.c -mbulk-memory -O -c -o temp.wasm

这是我从上面的样本中得到的:

  1. (module
  2. (type $t0 (func (param i32 i32)))
  3. (type $t1 (func (param i32)))
  4. (import "env" "__linear_memory" (memory $env.__linear_memory 0))
  5. (import "env" "__indirect_function_table" (table $env.__indirect_function_table 0 funcref))
  6. (func $memcpy_test (type $t0) (param $p0 i32) (param $p1 i32)
  7. (memory.copy
  8. (local.get $p0)
  9. (local.get $p1)
  10. (i32.const 128)))
  11. (func $memset_test (type $t1) (param $p0 i32)
  12. (memory.fill
  13. (local.get $p0)
  14. (i32.const 0)
  15. (i32.const 128)))
  16. (export "memcpy" (func $memcpy_test))
  17. (export "memset" (func $memset_test)))

这似乎是预期的结果。

今天关于Splunk 将第二个查询结果字段放入 Linux 主机的 Percentage Memory 的第一个查询中的讲解已经结束,谢谢您的阅读,如果想了解更多关于.NET Memory issues loading ~40 images, memory not reclaimed, potentially due to LOH fragmentation、ASP.NET – 如何在C#表上设置Cells-Width-Percentage、Attempted to read or write protected memory. This is often an indication that other memory is corrupt.、Clang 是否为 WebAssembly 的 memory.fill 和 memory.copy 提供内在函数?的相关知识,请在本站搜索。

本文标签: