pear os如何安装到从移动硬盘安装系统

[实践OK]Mysql严格模式开启, MySQL 严格模式 sql_mode,最主要是innodb的严格模式备查。mysql STRICT_TRANS_TABLES严格模式下提示Field 'id' doesn't have a default value。
引用地址:
注意: 该地址仅在今日23:59:59之前有效
背景:线上数据库报:mysql STRICT_TRANS_TABLES严格模式下提示Field 'ip' doesn't have a default value,线下测试机没有报错,外包开发时代码没法保证SQL全写运行无问题。INNODB加入后,还是不行:innodb_strict_mode = 1mysql& show variables&&like &%str%&;+--------------------+----------------+| Variable_name&&&&&&| Value&& |+--------------------+----------------+| innodb_strict_mode | ON&&&&| +--------------------+----------------+1 row in set (0.00 sec)外网的SQL有问题,内网的测试机db无问题,如下:REPLACE INTO `app_play_8` (`user_id`, `video_id`, `video_name`, `video_img`, `video_url`, `playtime`, `source`, `source_url`, `clienttype`, `position`) VALUES ('9;, '112c9654-52ed-11e1-b091-a4badb9;, '《2012春节动画狂欢曲》', 'http://p1./fmspic//becd73c6cc3f43c59add0fae-180.jpg', '/v-112c9654-52ed-11e1-b091-a4badb4696b6.html', , '哈妮哈妮', '//index.html', '1', '99')ERROR 1364 (HY000): Field 'ip' doesn't have a default value看似找到了,其实不然,和版本无关---另一台测试的db是13的,也是同样ip不能为空,但也不提示:Field 'ip' doesn't have a default value。找到了:这个我在我的虚拟机mysql5.6.12 上分别把线上的sql给建立和线下也建立,同时这个+--------------------+-------+| Variable_name&&&&&&| Value |+--------------------+-------+| innodb_strict_mode | OFF&& |+--------------------+-------+,虚拟机是会报没有ip的,所以,得出是mysql的版本造成的。5.6.11(测试),5.6.12(我的虚拟机),5.6.13线上。 12,13是一样的结果,得证。我这个关系不大:innodb_strict_mode尽管线上打开了,但是我的虚拟机配置没打开这个,依旧能提示:Field 'ip' doesn't have a default value。______后来,1)打开my.ini,加入:#Add Mysql's Innodb strict sql insert mode by:jackxiang date:
sql-mode=&STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION&
innodb_strict_mode = 1
2)重启:[root@localhost mysql]# ./bin/mysqld_safe --defaults-file=f &3)再插入OK有提示了:mysql& REPLACE INTO `app_play_8` (`user_id`, `video_id`, `video_name`, `video_img`, `video_url`, `playtime`, `source`, `source_url`, `clienttype`, `position`) VALUES ('9;, '112c9654-52ed-11e1-b091-a4badb9;, '《2012春节动画狂欢曲》', 'http://p1./fmspic//becd73c6cc3f43c59add0fae-180.jpg', '/v-112c9654-52ed-11e1-b091-a4badb4696b6.html', , '哈妮哈妮', '//index.html', '1', '99');ERROR 1364 (HY000): Field 'ip' doesn't have a default valuemysql& quit实践参考两篇文章:mysql STRICT_TRANS_TABLES严格模式下提示Field 'id' doesn't have a default value:/blog/view-411.htmlMysql Field * doesn't have a default value解决方法:.cn/s/blog_43ed7fh.htmlEOF Add:——————————————————————————————————————————————————————————————虽然说我们尽量在写程序的时候控制插入到数据库的数据,而不要用数据库去判断数据的对错,但是有时候为了方便还是需要数据库自身的容错能力来帮助我们达到目的的。举例说明:创建如下数据表[sql] view plaincopy&&&&CREATE TABLE `book` (&&&&&&&&`id` int(11) default NULL,&&&&&&&&`num` int(11) unsigned default NULL&&&&&&) ENGINE=InnoDB DEFAULT CHARSET=gbk&&&&&&insert into bookvalues(1,0),(2,0)&&执行update book set num='abc',竟然不报错,原因是没有启用严格模式。所以先执行set sql_mode=&STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION&,然后执行update book set num='abc',数据库就报错了如果想一劳永逸,那就直接把数据库配置文件my.ini中的相关参数设置为# Set the SQL mode to strictsql-mode=&STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION&——————————————————————————————————————————————————————————————解决办法:关闭MySQL的strict mode。具体做法:找到MySQL目录下的my.ini, 将其中的sql-mode=&STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION& 修改为sql-mode=&NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION&,重新启动 Mysql服务。
&&MySQL 严格模式 sql_mode 收藏虽然说我们尽量在写程序的时候控制插入到数据库的数据,而不要用数据库去判断数据的对错,但是有时候为了方便还是需要数据库自身的容错能力来帮助我们达到目的的。举例说明:创建如下数据表CREATE TABLE `book` (&&`id` int(11) default NULL,&&`num` int(11) unsigned default NULL) ENGINE=InnoDB DEFAULT CHARSET=gbkinsert into bookvalues(1,0),(2,0)执行update book set num='abc',竟然不报错,原因是没有启用严格模式。所以先执行set sql_mode=&STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION&,然后执行update book set num='abc',数据库就报错了
非严格模式:会对语法的限制降到最低,导致很多不规范的语句都可以执行,会导致歧义.严格模式:可以实现严格校检,使错误数据不能插入,从而保证数据准确性.来自:.cn/s/blog_505d197c0100l1bs.html来自:http://blog.csdn.net/ldb2741/article/details/5317803官网:/read.php?11,356#msg-581356作者:@地址:版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: justwinit 编辑于 16:46
[9/9]北京市海淀区中关村理想国际大厦18层 Address:Sina 18th floor Ideal plaza Zhongguancun Haidain
Beijing 100080, P.R.China
[1/9]深圳南山腾讯大厦8楼 Address:Tencent Plaza High-tech One Road, Middle Zone, High-new Science & Technology Park, Nanshan Distrcit, Shenzhen City, Guangdong Province 518057, P.R. China
[2/9]深圳南山腾讯大厦旁大族激光大厦三楼 Address:Han's Building,Kejizhongyi Avenue, Hi-tech Pack,Nanshan District, Shenzhen City, Guangdong Province 518057, P.R.China
[2012/10-Now]北京海淀区西三环中路10号望海楼B座7层央视国际网络有限公司 Address:Seaview floor, Haidian District No.10,West Sanhuan Road,Beijing 100142, P.R.China[实践OK]mysql 5.6 打开慢查询,Mysql新版本的慢查询配置和旧的版本不太一样。
引用地址:
注意: 该地址仅在今日23:59:59之前有效
背景:Mysql新版本的慢查询配置和旧的版本不太一样,为此,特转下这这篇文章,以备案。近来发现我们用程序写啥慢sql还不如包自己带呢,MySQL分支 Percona 5.6.15 发布: http://www./news/view/18ed41c ,这自己带着杀sql的功能: Percona5.6自身已支持杀死慢SQL, http://hcymysql./1218零、关闭mysql:
&&&&&& /usr/local/mysql/bin/mysqladmin -u root shutdown
一、Mysql启动参数 -u root:
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/f -uroot &
/usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/f --basedir=/usr/local/mysql --datadir=/data/db/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/db/mysql/localhost.localdomain.err --open-files-limit=65535 --pid-file=/data/db/mysql/localhost.localdomain.pid --socket=/tmp/mysqld.sock --port=3306
二、配置my.cnf如下:
long_query_time=2
slow_query_log=1
slow_query_log_file=/data/db/mysql/localhost-xiyou-slowsql.lo
mysql版本:mysql& select version();+------------+| version()&&|+------------+| 5.6.13-log |+------------+1 row in set (0.00 sec)[root@mysql_multi ~]# vi /f【mysqld3307】long_query_time=1#slow_query_logslow_query_log=1#slow_query_log_file=/data/mysql/mysqldata3307/log/slow-query.log#以前版本的参数格式跟5.6的不一致slow_query_log_file=/data/mysql/mysqldata3307/log/slow-query.log#将所有没有使用带索引的查询语句全部写到慢查询日志中log_queries_not_using_indexes=1 对 3307 端口的mysql:[root@mysql_multi ~]# mysqld_multi start 3307[root@mysql_multi ~]# netstat -nlp|grep mysqltcp&&&&&&&&0&&&&&&0 :::3306&&&&&&&&&&&&&&&&&&&& :::*&&&&&&&&&&&&&&&&&&&&&&&&LISTEN&&&&&&20211/mysqld&&&&&&&&tcp&&&&&&&&0&&&&&&0 :::3307&&&&&&&&&&&&&&&&&&&& :::*&&&&&&&&&&&&&&&&&&&&&&&&LISTEN&&&&&&18693/mysqld&&&&&&&&unix&&2&&&&&&[ ACC ]&&&& STREAM&&&& LISTENING&&&& 4/mysqld&&&&&&&&/data/mysql/mysqldata3306/sock/mysql.sockunix&&2&&&&&&[ ACC ]&&&& STREAM&&&& LISTENING&&&& 6/mysqld&&&&&&&&/data/mysql/mysqldata3307/sock/mysql.sockroot@localhost : mysql 01:00:16& show variables like '%slow%';ERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect...Connection id:&&&&2Current database: mysql+---------------------------+----------------------------------------------+| Variable_name&&&&&&&&&&&& | Value&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|+---------------------------+----------------------------------------------+| log_slow_admin_statements | OFF&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|| log_slow_slave_statements | OFF&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|| slow_launch_time&&&&&&&&&&| 2&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|| slow_query_log&&&&&&&&&&&&| ON&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& || slow_query_log_file&&&&&& | /data/mysql/mysqldata3307/log/slow-query.log |+---------------------------+----------------------------------------------+5 rows in set (0.00 sec)root@localhost : mysql 01:03:44& show variables like '%index%';+----------------------------------------+-------+| Variable_name&&&&&&&&&&&&&&&&&&&&&&&&&&| Value |+----------------------------------------+-------+| eq_range_index_dive_limit&&&&&&&&&&&&&&| 10&&&&|| innodb_adaptive_hash_index&&&&&&&&&&&& | ON&&&&|| innodb_cmp_per_index_enabled&&&&&&&&&& | OFF&& || log_bin_index&&&&&&&&&&&&&&&&&&&&&&&&&&|&&&&&& || log_queries_not_using_indexes&&&&&&&&&&| ON&&&&|| log_throttle_queries_not_using_indexes | 0&&&& || relay_log_index&&&&&&&&&&&&&&&&&&&&&&&&|&&&&&& |+----------------------------------------+-------+7 rows in set (0.00 sec)然后运行一个需要长时间才能执行完毕的sql,select sleep(2);使用mysqldumpslow 查看日志:/data/mysql/mysqldata3307/log/slow-query.log (直接使用cat 进行查看也可以)转自:http://blog.itpub.net//viewspace-1064074实践如下:一、vi /usr/local/mysql/f slow_query_log=1long_query_time = 2slow_query_log_file=/data/db/mysql/localhost-slow.log#将所有没有使用带索引的查询语句全部写到慢查询日志中log_queries_not_using_indexes=1 #如果开启了log_queries_not_using_indexes选项,slow query日志会充满过多的垃圾日志记录,这些快且高效的全表扫描查询(表小)会冲掉真正有用的slow queries记录。比如select * from category这样的查询也会被记录下来。二、mysql& show variables like '%slow%';+---------------------------+-----------------------------------+| Variable_name&&&&&&&&&&&& | Value&&&&&&&&&&&&&&&&&&&&&&&&&&&& |+---------------------------+-----------------------------------+| log_slow_admin_statements | OFF&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& || log_slow_slave_statements | OFF&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& || slow_launch_time&&&&&&&&&&| 2&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& || slow_query_log&&&&&&&&&&&&| ON&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|| slow_query_log_file&&&&&& | /data/db/mysql/localhost-slow.log |+---------------------------+-----------------------------------+三、du -sh /data/db/mysql/localhost-slow.log803M&&&&/data/db/mysql/localhost-slow.log四、Mysql 测试配置文件是否正确 my.cnf,那个nginx 有-t,mysql呢?一)这个没必要重启,直接 set @@global.slow_query_log=1;二)起动一个新端口的副本测试,有道理。mysql&&&show variables like '%slow%';+---------------------------+--------------------------------------------+| Variable_name&&&&&&&&&&&& | Value&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|+---------------------------+--------------------------------------------+| log_slow_admin_statements | OFF&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|| log_slow_slave_statements | OFF&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|| slow_launch_time&&&&&&&&&&| 2&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|| slow_query_log&&&&&&&&&&&&| ON&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& || slow_query_log_file&&&&&& | /data/db/mysql/localhost-xiyou-slowsql.log |+---------------------------+--------------------------------------------__________________________________________mysql5.6和5.5中打开slow_query_log的方式有所改变:mysql5.6.10关于慢查询的设置slow-query-log前两天,刚把开发用的环境升级为2008R2,,所以想试试5.6.10的64位的数据库,是在mysql的官方下载的win32x64版本,一共有200多M。发现里面只有一个默认的my.ini文件,想进行优化试试,结果发现老是启动不了。后来发现,主要是这个关于慢查询的设置变了,之前是:slow_query_loglong_query_time = 5log-slow-queries=slow.log现在必须要这种设置才行slow_query_log=1slow_query_log_file=slow.log看来从5.6.* 可能已经全面取消了log_slow_queries=slow.log这种写法了来自:/database/100.html作者:@地址:版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: justwinit 编辑于 16:26
[9/9]北京市海淀区中关村理想国际大厦18层 Address:Sina 18th floor Ideal plaza Zhongguancun Haidain
Beijing 100080, P.R.China
[1/9]深圳南山腾讯大厦8楼 Address:Tencent Plaza High-tech One Road, Middle Zone, High-new Science & Technology Park, Nanshan Distrcit, Shenzhen City, Guangdong Province 518057, P.R. China
[2/9]深圳南山腾讯大厦旁大族激光大厦三楼 Address:Han's Building,Kejizhongyi Avenue, Hi-tech Pack,Nanshan District, Shenzhen City, Guangdong Province 518057, P.R.China
[2012/10-Now]北京海淀区西三环中路10号望海楼B座7层央视国际网络有限公司 Address:Seaview floor, Haidian District No.10,West Sanhuan Road,Beijing 100142, P.R.China[简单实践]Linux c++上常用内存泄露检测工具有valgrind, Linux C/C++ 内存泄漏检测工具:Valgrind。
引用地址:
注意: 该地址仅在今日23:59:59之前有效
Linux c++上常用内存泄露检测工具有valgrind, Rational purify。Valgrind免费。Valgrind 可以在 32 位或 64 位 PowerPC/Linux 内核上工作。Valgrind工具包包含多个工具,如Memcheck,Cachegrind,Helgrind, Callgrind,Massif。下面分别介绍个工具的作用:Memcheck 工具主要检查下面的程序错误:o 使用未初始化的内存 (Use of uninitialised memory)o 使用已经释放了的内存 (Reading/writing memory after it has been free’d)o 使用超过 malloc分配的内存空间(Reading/writing off the end of malloc’d blocks)o 对堆栈的非法访问 (Reading/writing inappropriate areas on the stack)o 申请的空间是否有释放 (Memory leaks – where pointers to malloc’d blocks are lost forever)o malloc/free/new/delete申请和释放内存的匹配(Mismatched use of malloc/new/new [] vs free/delete/delete [])o src和dst的重叠(Overlapping src and dst pointers in memcpy() and related functions)Valgrind不检查静态分配数组的使用情况。Valgrind占用了更多的内存--可达两倍于你程序的正常使用量。如果你用Valgrind来检测使用大量内存的程序就会遇到问题,它可能会用很长的时间来运行测试2.1. 下载安装http://www.valgrind.org安装./make install2.2. 编译程序被检测程序加入 –g&& -fno-inline 编译选项保留调试信息。2.3. 内存泄露检测$ valgrind --leak-check=full --show-reachable=yes --trace-children=yes&&&&./iquery&& -f ../conf/se.conf_forum -t&& ~/eragon/forum_thread_data/f.log -NT&& -cache 0其中--leak-check=full 指的是完全检查内存泄漏,--show-reachable=yes是显示内存泄漏的地点,--trace-children=yes是跟入子进程。当程序正常退出的时候valgrind自然会输出内存泄漏的信息。 来自: /benbendy/blog/item/905fbfab211c709.html 参看:http://zyan.cc/post/419/—————————————————试着调一个epoll的多进程测试小程序————————————————————刚运行起来没有泄漏,多请求几次后再ctrl+C退出时,发现有泄漏情况了,如下所示:[root@test multepoolserver]# valgrind --tool=memcheck --leak-check=full ./multipepollserver
[root@test multepoolserver]# valgrind --tool=memcheck --leak-check=full multipepollserver /
valgrind: multipepollserver: command not found
[root@test multepoolserver]# valgrind --tool=memcheck --leak-check=full multipepollserver
valgrind: multipepollserver: command not found
[root@test multepoolserver]# valgrind --tool=memcheck --leak-check=full multipepollserver
valgrind: multipepollserver: command not found
[root@test multepoolserver]# valgrind --tool=memcheck --leak-check=full ./multipepollserver
==24877== Memcheck, a memory error detector
==24877== Copyright (C) , and GNU GPL'd, by Julian Seward et al.
==24877== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==24877== Command: ./multipepollserver
==24877== Conditional jump or move depends on uninitialised value(s)
==24877==&&&&at 0x3C9A2436B0: vfprintf (in /lib64/libc-2.5.so)
==24877==&&&&by 0x3C9A263B48: vsprintf (in /lib64/libc-2.5.so)
==24877==&&&&by 0x4019A1: prename_setproctitle(char const*, ...) (multipepollserver.cpp:286)
==24877==&&&&by 0x40298D: main (multipepollserver.cpp:481)
==24877== Use of uninitialised value of size 8
==24877==&&&&at 0x4A08EA2: strlen (mc_replace_strmem.c:404)
==24877==&&&&by 0x3C9A246B68: vfprintf (in /lib64/libc-2.5.so)
==24877==&&&&by 0x3C9A263B48: vsprintf (in /lib64/libc-2.5.so)
==24877==&&&&by 0x4019A1: prename_setproctitle(char const*, ...) (multipepollserver.cpp:286)
==24877==&&&&by 0x40298D: main (multipepollserver.cpp:481)
==24877== Use of uninitialised value of size 8
==24877==&&&&at 0x4A08EB4: strlen (mc_replace_strmem.c:404)
==24877==&&&&by 0x3C9A246B68: vfprintf (in /lib64/libc-2.5.so)
==24877==&&&&by 0x3C9A263B48: vsprintf (in /lib64/libc-2.5.so)
==24877==&&&&by 0x4019A1: prename_setproctitle(char const*, ...) (multipepollserver.cpp:286)
==24877==&&&&by 0x40298D: main (multipepollserver.cpp:481)
==24877== Use of uninitialised value of size 8
==24877==&&&&at 0x3C9A26E256: _IO_default_xsputn (in /lib64/libc-2.5.so)
==24877==&&&&by 0x3C9A246502: vfprintf (in /lib64/libc-2.5.so)
==24877==&&&&by 0x3C9A263B48: vsprintf (in /lib64/libc-2.5.so)
==24877==&&&&by 0x4019A1: prename_setproctitle(char const*, ...) (multipepollserver.cpp:286)
==24877==&&&&by 0x40298D: main (multipepollserver.cpp:481)
parent process id 24877
==24877== Warning: ignored attempt to set SIGKILL handler in sigaction();
==24877==&&&&&&&&&&the SIGKILL signal is uncatchable
child process id 24878,parent id 24877
==24878== Warning: ignored attempt to set SIGKILL handler in sigaction();
==24878==&&&&&&&&&&the SIGKILL signal is uncatchable
进入线程举旗:sync_additional_writing_worker...
==24878== Conditional jump or move depends on uninitialised value(s)
==24878==&&&&at 0x3C9A2436B0: vfprintf (in /lib64/libc-2.5.so)
==24878==&&&&by 0x3C9A263B48: vsprintf (in /lib64/libc-2.5.so)
==24878==&&&&by 0x4019A1: prename_setproctitle(char const*, ...) (multipepollserver.cpp:286)
==24878==&&&&by 0x402B93: main (multipepollserver.cpp:558)
thread id is ,procees id is 24877,waiting for into while...
==24878== Warning: invalid file descriptor -1 in syscall close()
==24878== Syscall param epoll_ctl(event) points to uninitialised byte(s)
==24878==&&&&at 0x3C9A2D3F9A: epoll_ctl (in /lib64/libc-2.5.so)
==24878==&&&&by 0x401DAA: Process(int, int*) (multipepollserver.cpp:102)
==24878==&&&&by 0x402BA0: main (multipepollserver.cpp:560)
==24878==&&Address 0xfff000688 is on thread 1's stack
浏览器多请求几次,于是出现了 definitely lost,如下:
==24877== HEAP SUMMARY:
==24877==&&&& in use at exit: 1,901 bytes in 31 blocks
==24877==&& total heap usage: 32 allocs, 1 frees, 2,469 bytes allocated
==24878== HEAP SUMMARY:
==24878==&&&& in use at exit: 1,906 bytes in 60 blocks
==24878==&& total heap usage: 61 allocs, 1 frees, 2,474 bytes allocated
==24878== 293 (240 direct, 53 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 4
==24878==&&&&at 0x4A072D0: malloc (vg_replace_malloc.c:291)
==24878==&&&&by 0x401AF4: prename_setproctitle_init(int, char**, char**) (multipepollserver.cpp:261)
==24878==&&&&by 0x402B80: main (multipepollserver.cpp:557)
==24878== 1,613 (240 direct, 1,373 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
==24878==&&&&at 0x4A072D0: malloc (vg_replace_malloc.c:291)
==24878==&&&&by 0x401AF4: prename_setproctitle_init(int, char**, char**) (multipepollserver.cpp:261)
==24878==&&&&by 0x40297A: main (multipepollserver.cpp:480)
==24878== LEAK SUMMARY:
==24878==&&&&definitely lost: 480 bytes in 2 blocks
==24878==&&&&indirectly lost: 1,426 bytes in 58 blocks
==24878==&&&&&&possibly lost: 0 bytes in 0 blocks
==24878==&&&&still reachable: 0 bytes in 0 blocks
==24878==&&&&&&&& suppressed: 0 bytes in 0 blocks
==24878== For counts of detected and suppressed errors, rerun with: -v
==24878== Use --track-origins=yes to see where uninitialised values come from
==24878== ERROR SUMMARY: 41 errors from 8 contexts (suppressed: 4 from 4)
==24877== 288 bytes in 1 blocks are possibly lost in loss record 1 of 3
==24877==&&&&at 0x4A0652F: calloc (vg_replace_malloc.c:618)
==24877==&&&&by 0x3C9920FEF2: _dl_allocate_tls (in /lib64/ld-2.5.so)
==24877==&&&&by 0x3C9AE06C29: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.5.so)
==24877==&&&&by 0x402A36: main (multipepollserver.cpp:512)
==24877== 1,613 (240 direct, 1,373 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3
==24877==&&&&at 0x4A072D0: malloc (vg_replace_malloc.c:291)
==24877==&&&&by 0x401AF4: prename_setproctitle_init(int, char**, char**) (multipepollserver.cpp:261)
==24877==&&&&by 0x40297A: main (multipepollserver.cpp:480)
==24877== LEAK SUMMARY:
==24877==&&&&definitely lost: 240 bytes in 1 blocks
==24877==&&&&indirectly lost: 1,373 bytes in 29 blocks
==24877==&&&&&&possibly lost: 288 bytes in 1 blocks
==24877==&&&&still reachable: 0 bytes in 0 blocks
==24877==&&&&&&&& suppressed: 0 bytes in 0 blocks
==24877== For counts of detected and suppressed errors, rerun with: -v
==24877== Use --track-origins=yes to see where uninitialised values come from
==24877== ERROR SUMMARY: 21 errors from 6 contexts (suppressed: 4 from 4)
[root@test multepoolserver]#
————————————————返回结果中的“definitely lost: 480 bytes in 2 blocks”表示发生内存泄漏—————————————————
重点性查一下,multipepollserver.cpp:261 行,main (multipepollserver.cpp:512):
==24878==&&&&by 0x401AF4: prename_setproctitle_init(int, char**, char**) (multipepollserver.cpp:261)
==24878==&&&&by 0x402B80: main (multipepollserver.cpp:557)
==24878== 1,613 (240 direct, 1,373 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
==24878==&&&&at 0x4A072D0: malloc (vg_replace_malloc.c:291)
==24878==&&&&by 0x401AF4: prename_setproctitle_init(int, char**, char**) (multipepollserver.cpp:261)
==24878==&&&&by 0x40297A: main (multipepollserver.cpp:480)
==24878== LEAK SUMMARY:
==24878==&&&&definitely lost: 480 bytes in 2 blocks
==24877==&&&&by 0x402A36: main (multipepollserver.cpp:512)
==24877== 1,613 (240 direct, 1,373 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3
==24877==&&&&at 0x4A072D0: malloc (vg_replace_malloc.c:291)
==24877==&&&&by 0x401AF4: prename_setproctitle_init(int, char**, char**) (multipepollserver.cpp:261)
==24877==&&&&by 0x40297A: main (multipepollserver.cpp:480)
==24877== LEAK SUMMARY:
==24877==&&&&definitely lost: 240 bytes in 1 blocks
一查原因,两条遗漏:for (i = 0; envp[i] != NULL; i++)&&&&&&&&&&&&&&&&&& &&&&environ[i] = strdup(envp[i]);//xstrdup(envp[i]);environ[i] = NULL;1.这个for没有把:environ[i] = NULL; 给括号进来,没有释放掉?不对:strdup(gdb) print *envp$2 = 0x7fff72df6afa &HOSTNAME=test.local&$4 = 0x7fff72df6ac8 &/home/xiangdong/multepoolserver/multipepollserver&2.没有free掉char *:char * httpmut_prename_child_buf=&worker process&; /* 原命令行参数:子进程名字。 */ prename_setproctitle(&[httpmut: worker process] %s&, httpmut_prename_child_buf);free(httpmut_prename_child_buf);//这个得free掉。==26827==&&&&by 0x4029CA: main (multipepollserver.cpp:484)(gdb) cContinuing.Program received signal SIGSEGV, Segmentation fault.0xa27272e in free () from /lib64/libc.so.6(gdb) bt#0&&0xa27272e in free () from /lib64/libc.so.6#1&&0x29e7 in main (argc=1, argv=0x7fff72df4e08, envp=0x7fff72df4e18) at multipepollserver.cpp:486用ab.exe压力一下?D:\wamp\bin\apache\apache2.2.22\bin\ab.exe -c 1000 -n 1000 会提示:[http://]hostname[:port]/pathD:\wamp\bin\apache\apache2.2.22\bin\ab.exe -c 1000 -n 1000 /C语言调指针可真是个小心活儿,还得有工具,有经验啊EOF。作者:@地址:版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: justwinit 编辑于 16:59
[9/9]北京市海淀区中关村理想国际大厦18层 Address:Sina 18th floor Ideal plaza Zhongguancun Haidain
Beijing 100080, P.R.China
[1/9]深圳南山腾讯大厦8楼 Address:Tencent Plaza High-tech One Road, Middle Zone, High-new Science & Technology Park, Nanshan Distrcit, Shenzhen City, Guangdong Province 518057, P.R. China
[2/9]深圳南山腾讯大厦旁大族激光大厦三楼 Address:Han's Building,Kejizhongyi Avenue, Hi-tech Pack,Nanshan District, Shenzhen City, Guangdong Province 518057, P.R.China
[2012/10-Now]北京海淀区西三环中路10号望海楼B座7层央视国际网络有限公司 Address:Seaview floor, Haidian District No.10,West Sanhuan Road,Beijing 100142, P.R.China

我要回帖

更多关于 pear os 的文章

 

随机推荐