ram

How do you determine the amount of Linux system RAM in C++?

旧城冷巷雨未停 提交于 2020-01-09 06:21:21
问题 I just wrote the following C++ function to programatically determine how much RAM a system has installed. It works, but it seems to me that there should be a simpler way to do this. Can someone tell me if I'm missing something? getRAM() { FILE* stream = popen( "head -n1 /proc/meminfo", "r" ); std::ostringstream output; int bufsize = 128; while( !feof( stream ) && !ferror( stream )) { char buf[bufsize]; int bytesRead = fread( buf, 1, bufsize, stream ); output.write( buf, bytesRead ); } std:

TotalPhysicalMemory from VisualBasic.Devices slightly different from WMI Win32_PhysicalMemory

雨燕双飞 提交于 2020-01-06 17:56:26
问题 So my application requires knowing total RAM available. At least 4 different ways exist, as far as I'm concerned: Query Windows Menagement Instrumentation (WMI) Get it from Microsoft.VisualBasic.Devices.ComputerInfo.TotalPhysicalMemory Query WinAPI Use P-Invoke I like the first two, hovewer they give slightly different results on my machine (2 sticks of 2GB each, Windows 8.1 64 bit). The code I use to get it from VisualBasic dll: class Program { private static readonly Lazy<ComputerInfo>

Assessing how large a file (How much RAM it will take) will be in R before loading it

前提是你 提交于 2020-01-05 09:10:05
问题 I was wondering if there's some function that given a file name + path can asses how much RAM R will need to use it? i want to be able to know this info before I'm loading it. 回答1: You can use 'fstat' http://linux.die.net/man/2/fstat It will report information about your file, such as actual filesize. struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /*

Assessing how large a file (How much RAM it will take) will be in R before loading it

£可爱£侵袭症+ 提交于 2020-01-05 09:08:54
问题 I was wondering if there's some function that given a file name + path can asses how much RAM R will need to use it? i want to be able to know this info before I'm loading it. 回答1: You can use 'fstat' http://linux.die.net/man/2/fstat It will report information about your file, such as actual filesize. struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /*

How to get CPU load / RAM usage out of QNX?

喜你入骨 提交于 2020-01-03 05:38:10
问题 I'm currently trying to get information about the CPU load and RAM usage out of an PowerPC with QNX running on it. The idea is to write that information in a text file with a time stamp over a certain amount of time, but this ain't my problem here once I have the information as a "standard value". My programm will be in C++ and I already did this kind of program for Windows (via PDH API). Maybe you have page like this but for QNX? Probably I'm looking for the wrong keywords. Can you help me

基于FPGA的SPI协议及设计实现

江枫思渺然 提交于 2020-01-01 05:19:06
基于FPGA的SPI协议及设计实现 博主微信:flm13724054952,不懂的有疑惑的也可以加微信咨询,欢迎大家前来投稿,谢谢! 引言介绍 在电子通信领域里采用的通信协议有IIC,SPI,UART,FSMC等协议。本文将基于FPGA来介绍并设计标准的SPI总线协议,实现FPGA与MCU的数据通信。SPI是英语Serial Peripheral Interface的缩写,顾名思义就是串行外围设备接口。SPI是一种高速的、全双工、同步通信总线,标准的SPI也仅仅使用4个引脚,常用于FPGA和 EEPROM、FLASH、数字信号处理器等器件的数据通信。 SPI的原理介绍 SPI的通信方式是主从方式通信。这种模式通常只有一个主机和一个从机或者一个主机和多个从机;一般来说,标准的SPI协议是由4根线组成,分别是SSEL(从机片选使能信号,也写作 SCS,CSB)、SCLK(串行时钟,也写作SCK)、MOSI(主机输出从机输入Master Output/Slave Input)和MISO(主机输入从机输出Master Input/Slave Output)。有的SPI接口芯片带有中断信号INT,也有的SPI接口芯片只作为从机使用故只有MISO口,不过这里本文将基于FPGA来介绍并设计标准的SPI总线协议。 SPI的标准接口 CSB:从设备片选使能信号。注意的是

stm32 堆和栈(stm32 Heap & Stack)【worldsing笔记】

ⅰ亾dé卋堺 提交于 2019-12-31 19:58:09
关于堆和栈已经是程序员的一个月经话题,大部分有是基于os层来聊的。 那么,在赤裸裸的单片机下的堆和栈是什么样的分布呢?以下是网摘: 刚接手STM32时,你只编写一个 int main() { while(1); } BUILD://Program Size: Code=340 RO-data=252 RW-data=0 ZI-data=1632 编译后,就会发现这么个程序已用了1600多的RAM,要是在51单片机上,会心疼死了,这1600多的RAM跑哪儿去了, 分析map,你会发现是堆和栈占用的,在startup_stm32f10x_md.s文件中,它的前面几行就有以上定义, 这下该明白了吧。 Stack_Size EQU 0x00000400 Heap_Size EQU 0x00000200 以下引用网上资料 理解堆和栈的区别 (1)栈区(stack):由编译器自动分配和释放,存放函数的参数值、局部变量的值等,其操作方式类似 于数据结构中的栈。 (2)堆区(heap):一般由程序员分配和释放,若程序员不释放,程序结束时可能由操作系统回收。分配 方式类似于数据结构中的链表。 (3)全局区(静态区)(static):全局变量和静态变量的存储是放在一块的,初始化的全局变量和静态 变量在一块区域,未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。程序结束后由系 统自动释放。 (4

High Java memory usage even for small programs

若如初见. 提交于 2019-12-30 02:36:08
问题 I have a couple of simple applications written in java, one of them written to act as a widget. What surprised me how much RAM even small applications use. I wrote the following to see if it is a bug in my programs, or a general Java issue: public class ram { public static void main(String[] args){ while(true)System.out.print("Hello World");//while loop to give me time to check RAM usage } } Then compiled and ran it with java ram and it gave me the following RAM usage: The process java (with

Python large variable RAM usage

百般思念 提交于 2019-12-29 06:49:14
问题 Say there is a dict variable that grows very large during runtime - up into millions of key:value pairs. Does this variable get stored in RAM, effectively using up all the available memory and slowing down the rest of the system? Asking the interpreter to display the entire dict is a bad idea, but would it be okay as long as one key is accessed at a time? 回答1: Yes, the dict will be stored in the process memory. So if it gets large enough that there's not enough room in the system RAM, then

When using -Xmx flag, what happens if the argument given exceed physical memory?

落花浮王杯 提交于 2019-12-25 17:01:41
问题 When using -Xmx flag, what happens if the argument given exceed physical memory? Also is there any way to explicitly make JVM to use a specific amount of memory using paging? 回答1: See for yourself: JVM fails in getting enough memory for the heap and exits. I don't think there is a way to make JVM use a specific amount of memory for paging, but you can use: -XX:+|-UseLargePages --for large page support and -XXLargePageSizeInBytes=<n> --for specifying how large your large pages can be. Look at