golang ---获取内存信息
package main import (
"fmt"
"syscall"
"unsafe"
) var kernel = syscall.NewLazyDLL("Kernel32.dll") type memoryStatusEx struct {
cbSize uint32
dwMemoryLoad uint32
ullTotalPhys uint64 // in bytes
ullAvailPhys uint64
ullTotalPageFile uint64
ullAvailPageFile uint64
ullTotalVirtual uint64
ullAvailVirtual uint64
ullAvailExtendedVirtual uint64
} func main() { GlobalMemoryStatusEx := kernel.NewProc("GlobalMemoryStatusEx")
var memInfo memoryStatusEx
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
mem, _, _ := GlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
if mem == 0 {
return
}
fmt.Println("total :=", memInfo.ullTotalPhys)
fmt.Println("free=:", memInfo.ullAvailPhys) }
输出结果:
total := 17054044160
free=: 12900540416
golang ---获取内存信息的更多相关文章
- Android 获取内存信息
由于工作需要,研究了一下android上获取内存信息的方法,总结如下: 1.SDK获取 在Java层利用API获取很简单,直接使用ActivityManager.MemoryInfo类即可,代码如下: ...
- linux通过脚本获取内存信息
1 原理 脚本中通过执行free获取内存信息,然后将文本信息通过“空格”分隔符分割成字符串数组将不同信息提取出来,最后通过bc计算出百分比 2 脚本 #!/bin/shHOSTNAME=`hostna ...
- PHP检测获取内存信息
PHP也可以检测获取到Windows的内存信息,而且代码还挺简单,无意发现的,觉得以后能用上,在此与大家分享. 本代码将得到总内存.初始使用等内存信息: <?php echo "初始: ...
- C#通过WinAPI获取内存信息,32位64位可用
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runti ...
- golang ---获取磁盘信息
package main import ( "fmt" "github.com/StackExchange/wmi" ) type Storage struct ...
- GetSystemInfo 和 GlobalMemoryStatus获取系统信息,内存信息
// GetSystemInfo.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #in ...
- 使用python获取CPU和内存信息的思路与实现(linux系统)
linux里一切皆为文件,在linux/unix的根文件夹下,有个/proc文件夹,这个/proc 是一种内核和内核模块用来向进程(process)发送信息的机制(所以叫做"/proc&qu ...
- python使用psutil获取服务器信息
>>> import psutil 获取cpu信息>>> psutil.cpu_times()scputimes(user=128258.38, nice=12.2 ...
- Powershell获取硬件信息
1.获取系统的BIOS的信息: Get-WMIObject -Class Win32_BIOS 2.获取内存信息: Get-WMIObject -Class Win32_PhysicalMemory ...
随机推荐
- 干货 | 10分钟带你掌握branch and price(分支定价)算法超详细原理解析
00 前言 相信大家对branch and price的神秘之处也非常好奇了.今天我们一起来揭秘该算法原理过程.不过,在此之前,请大家确保自己的branch and bound和column gene ...
- mac 下的 tree 命令 终端展示你的目录树结构
相信很多使用过Linux的用户都用过tree命令,它可以像windows的文件管理器一样清楚明了的显示目录结构.mac 下使用 brew包管理工具安装 tree 前提:安装了homebrew(安装指令 ...
- freemarker null异常详解及兼容模式
在读取user的时候,因为为空,报错了,错误处的代码是这样的 <#if user> 其实准确的写法应该是 <#if user??> 如果要消除错误,需要把前端代码修后成后面这种 ...
- 【转】git branch 命令查看分支、删除远程分支、本地分支
git branch 命令操作 1.查看本地分支 : git branch 前面带有*号的是当前分支 2 .删除本地分支: git branch -d [branchname] 提示删除了一个名为li ...
- android: 结合BottomNavigationView、ViewPager和Fragment 实现左右滑动的效果
主界面:MainActivity package com.yongdaimi.android.androidapitest; import android.os.Bundle; import andr ...
- IDS,IPS,IPD
什么是IDP - 百度文库https://wenku.baidu.com/view/c500cf35eefdc8d376ee3220.html
- PAT 甲级 1079 Total Sales of Supply Chain (25 分)(简单,不建树,bfs即可)
1079 Total Sales of Supply Chain (25 分) A supply chain is a network of retailers(零售商), distributor ...
- accept 和 content-Type区别
accept表示 客服端(浏览器)支持的类型,也是希望服务器响应发送回来的的数据类型. 例如:Accept:text/xml; ,也就是希望服务器响应发送回来的是xml文本格式的内容 区别: 1.Ac ...
- [LeetCode] 245. Shortest Word Distance III 最短单词距离 III
This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as ...
- [LeetCode] 377. Combination Sum IV 组合之和 IV
Given an integer array with all positive numbers and no duplicates, find the number of possible comb ...