您的位置:首页 > 其它

linx常用查看命令和内存分配及释放

2014-07-06 10:54 176 查看
1.命令行

运行时间多久:uptime

查看时间日期:

date:date -s '2014-7-4 10:35:20'

hwcloc

查看内存分配:

top

free:http://blog.csdn.net/wwww1988600/article/details/20545969

查看信息:

cat main_control.log

输入信息:

echo in >sys/class/gpio/gpio105/direcation

echo 1 >sys/class/gpio/gpio105/value

2.内存分配

  char buffer[200],如果这个函数在test(){*}内定义,属于栈分配,main调用test后会系统释放

  char buffer=malloc(size)属于堆分配,需要动态释放free();buffer=NULL;

  char str[] = "Hello world!";这个和第一种同属一种情况,不能释放只能函数运行完系统自动释放栈

new/malloc (char *str=(char*)malloc(10*sizeof(char))   / char *str=new char[10] )靠delete/free释放 或者程序结束
[auto] char str[10]离开变量的作用域释放(auto可以省略)
static char str[10]程序结束
const char *str = ""同上

  只有使用malloc()在栈空间开辟的动态内存才能被释放!
  c++中有这个char *buf=new char[100],对应释放delet []buf; buf =NULL;
http://blog.sina.com.cn/s/blog_866441e401013a6p.html

  内存泄露检测http://blog.163.com/crazy20070501@126/blog/static/128659465201382511845982/

  char *buffer和buffer[20]的区别http://blog.sina.com.cn/s/blog_472346470100cc1g.html

最后附上励志博客:毕业后5年的差别

http://blog.csdn.net/wwww1988600/article/details/7437332
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: