Giter VIP home page Giter VIP logo

Comments (12)

tianshiyeben avatar tianshiyeben commented on May 22, 2024

Thank you. I think you're right. I'll fix it.

from wgcloud.

tianshiyeben avatar tianshiyeben commented on May 22, 2024

I checked the sigar data. Used includes buffers and cached
,And I've verified that it's right, with very little error

from wgcloud.

tianshiyeben avatar tianshiyeben commented on May 22, 2024

I've verified it. Now it seems that it should be correct. You can test the code again. Maybe you can improve the code and send the improved code here later.

from wgcloud.

LangInteger avatar LangInteger commented on May 22, 2024

Where did you get access to sigar doc, the official wiki doesn't response to me.

from wgcloud.

LangInteger avatar LangInteger commented on May 22, 2024

I checked the sigar data. Used includes buffers and cached
,And I've verified that it's right, with very little error

With this theory, the calculation process is right.

  • My machine get s 1.0GB memory in total, with 116MB free , so the used + cached/buffered is 907, leads to 907/1024 = 88% memory usage.

But as I said,

I think there maybe a more reasonable method to calculate memory usage like this with formula:
Memory Utilization (%) = 100 -(((MemFree + Buffers + Cached)*100)/maxValue)

The key point is that I think the buffered/cached memory should not be calculated into used memory, it's still can be applied for new applications. Some reference:

  • Meaning of the buffers/cache line in the output of free:
    • It gives the original value for used minus the sum buffers+cached and the original value for free plus the sum buffers+cached, hence its title. These new values are often more meaningful
    • Linux (like most modern OS) will always try to use free RAM for caching stuff, so Mem: free will almost always be very low. Therefore the line -/+ buffers/cache: is shown, because it shows how much memory is free when ignoring caches; caches will be freed automatically if memory gets scarce, so they do not really matter.

I'm not a professional operations engineer and don't know how you check the memory usage of your machine in daily work. You may catch the factors I mentioned above and reconsider which way is better.

from wgcloud.

LangInteger avatar LangInteger commented on May 22, 2024

As for the code part, I can't see the buffered/cached memory field via the decompiled sigar source code.

public class Mem implements Serializable {
  private static final long serialVersionUID = 10181L;
  long total = 0L;
  long ram = 0L;
  long used = 0L;
  long free = 0L;
  long actualUsed = 0L;
  long actualFree = 0L;
  double usedPercent = 0.0D;
  double freePercent = 0.0D;

  public Mem() {
  }
}

You may give the actualUsed /actualFree a try, they may give us a more meaningful result.

from wgcloud.

tianshiyeben avatar tianshiyeben commented on May 22, 2024

可以用中文交流吗,我也不是专业运维工程师,也在交流和学习。
要不我们先关闭这个issue吧,等有好的解决方案时候再修复它。可以吗

from wgcloud.

LangInteger avatar LangInteger commented on May 22, 2024

可以,我觉得 sigar 的 Mem 类提供的 actualUsed /actualFree 就挺像是修正后的已使用内存/未使用内存。得空我验证下。

用英文是因为很多名词我翻译的不好,容易理解偏差。

from wgcloud.

LangInteger avatar LangInteger commented on May 22, 2024

上面提到的资料:

值得一看

from wgcloud.

LangInteger avatar LangInteger commented on May 22, 2024

另外,sigar 这个类库好老了,我看快十年没动代码了。

from wgcloud.

tianshiyeben avatar tianshiyeben commented on May 22, 2024

from wgcloud.

tianshiyeben avatar tianshiyeben commented on May 22, 2024

from wgcloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.