1.我写的C++程序,包含C++和Python混合编程,涉及用C++创建Python解释器并执行Python逻辑代码,回避了Python多线程,在redhat6.5的服务器上编译通过,编译环境:Python 2.7.11,g++ 4.x.x
2.login上去服务器之后,启动程序时dump,报内存泄漏;
3.于是source ~/.bash_profile
十几遍,(不确定的一个数字,可能十遍,也可能二十遍,在这之间)然后再启动,正常运行了。杀掉程序,再启动,没问题,不需要再source ~/.bash_profile
;
4.bahsh_profile里确实写了程序运行所需要的消息引擎的库路径,如果重新编译了引擎,是可能要重新source的;
5.如果退出登录,重新登录,又返回到2所描述的情形;
6.同样的代码、程序,在centos6.5上运行没有出现这样的问题;
7.服务器无法联网,内部私密服务器,安装包都需要离线安装,很麻烦。
ringa_lee2017-04-17 14:51:53
bash_profile contains environment variables. After execution, the environment variables are written. These environment variables will be visible in subsequent program runs under this account.
When you log in again or recompile the engine, the environment variables may become invalid.
伊谢尔伦2017-04-17 14:51:53
Don’t write the library path in scripts such as bash_profile. bash_profile relies on the user’s interactive login behavior and is unreliable.
It is estimated that your repeated execution caused certain environment variables to be continuously added, but it was able to run by accident.
Create a text file such as msgeng.conf in /etc/ld.so.conf.d/, the content of which is the absolute path to the directory where your library is located. Then sudo ldconfig, once and for all.