[英]Memory leak in 32 bit CPU processor and no leak in 64 bit processor CPU
I have a C code that runs without any memory leak in 64 bit CPU processor but shows leak in 32 bit processor. 我有一个C代码,在64位CPU处理器中运行时没有任何内存泄漏,但在32位处理器中却显示泄漏。 What can be the reason for it.
可能是什么原因。 GCC 4.1.2 is the compiler and Debian is the operating system.
GCC 4.1.2是编译器,Debian是操作系统。
Keep in mind that even though your own code is the same, you are still running two distinct programs -- there are different runtime libraries they are linked against. 请记住,即使您自己的代码相同,您仍在运行两个不同的程序-它们链接到不同的运行时库。 It could be that some aspect of your code is triggering a leak in one runtime and not another.
可能是代码的某些方面在一个运行时而不是另一个运行时触发了泄漏。 If that is the case, it can occur in one of two ways:
如果真是这样,它可能会以两种方式之一发生:
a) You've done nothing badly. a)你做得不好。 The problem is in the 32-bit runtime.
问题出在32位运行时中。
or 要么
b) You have something wrong, but something defensive in the 64-bit runtime is masking it. b)您有问题,但是在64位运行时中有防御措施正在掩盖它。
Really hard to tell without the code. 没有代码真的很难说。 Things that can go wrong
可能出错的事情
signed
or unsigned
. signed
或unsigned
。 If you have implicit assumptions on the width of of these, you may have all kind of things: overflow, undefined behavior, compiler specific behavior int
. int
。 If in reality it returns a pointer (eg) you are in trouble. int
conversions (or the other way round) int
转换的指针(或反之) Your compiler is quite old. 您的编译器很旧。 You probably should try do obtain something more recent, if possible, or try something different like
clang
. 如果可能的话,您可能应该尝试获取较新的内容,或者尝试使用类似
clang
。
Compile with all warnings on -Wall -Wextra
... and work on your code until it doesn't have any warning at all. 编译
-Wall -Wextra
...上的所有警告,并处理您的代码,直到完全没有任何警告为止。
If your problem persists run it with valgrind
as @unwind suggested. 如果问题仍然存在,请使用
valgrind
运行,如@unwind建议。
Then with a concrete problem some back here, so we might help you. 然后有一个具体的问题,请回到这里,以便我们为您提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.