由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请教一个C内存泄露问题
相关主题
问个google面试题某银行的笔试题
哪里有讲k-way merge的?A simple problem on correlation coefficient
一个有关数组的面试题 (难度较高)问个题: 找read-only array中duplicate的数
问几个问题 (1)array a1,a2,... ,an, b1,b2,..., bn
微软一个面试题请教一道题
C++ 一小题问一道题
一道面试题大家刷leetcode的速度有多块?
amazon phone interviewjavascript的一个问题:不能用loop,不能用library,怎么来remove array里的偶数?
相关话题的讨论汇总
话题: int话题: variable话题: used话题: size话题: dimension
进入JobHunting版参与讨论
1 (共1页)
g****y
发帖数: 436
1
源代码就是一个2d数组的分配和删除:
编译运行以后发现,程序占用内存按照 4K/单位时间 的速度增加,请问这是怎么回事
呢?
#include
#include
int main()
{
while(1){
int i; /* general purpose variable used for loop index */
int j; /* general purpose variable used for loop index */
int **a; /* this is the array name */
int size_x; /* this variable will be used for the first dimension */
int size_y; /* this variable will be used for the second dimension */
/* suppose we want an array of int: a[5][3] */
size_x =
g****y
发帖数: 436
2
下面这个代码更能说明问题,内存占用上升到了几百M
#include
#include
int main()
{
int gaga = 10000000;
while(gaga-- > 0){
int i; /* general purpose variable used for loop index */
int j; /* general purpose variable used for loop index */
int **a; /* this is the array name */
int size_x; /* this variable will be used for the first dimension */
int size_y; /* this variable will be used for the second dimension */
/* suppose we want an array of int: a[5][3] */
size_x =

【在 g****y 的大作中提到】
: 源代码就是一个2d数组的分配和删除:
: 编译运行以后发现,程序占用内存按照 4K/单位时间 的速度增加,请问这是怎么回事
: 呢?
: #include
: #include
: int main()
: {
: while(1){
: int i; /* general purpose variable used for loop index */
: int j; /* general purpose variable used for loop index */

t******r
发帖数: 88
3

~~~~~~shit...幸好你的size_y < size_x
回事

【在 g****y 的大作中提到】
: 下面这个代码更能说明问题,内存占用上升到了几百M
: #include
: #include
: int main()
: {
: int gaga = 10000000;
: while(gaga-- > 0){
: int i; /* general purpose variable used for loop index */
: int j; /* general purpose variable used for loop index */
: int **a; /* this is the array name */

h**c
发帖数: 2376
4
呵呵

【在 t******r 的大作中提到】
:
: ~~~~~~shit...幸好你的size_y < size_x
: 回事

1 (共1页)
进入JobHunting版参与讨论
相关主题
javascript的一个问题:不能用loop,不能用library,怎么来remove array里的偶数?微软一个面试题
一个面试题: 如何处理内存泄露(memory leak)C++ 一小题
问一下permutation的time complexity问题一道面试题
删除node从list, 这个有内存泄露么,怎么释放内存,对于那个被删除的节点?amazon phone interview
问个google面试题某银行的笔试题
哪里有讲k-way merge的?A simple problem on correlation coefficient
一个有关数组的面试题 (难度较高)问个题: 找read-only array中duplicate的数
问几个问题 (1)array a1,a2,... ,an, b1,b2,..., bn
相关话题的讨论汇总
话题: int话题: variable话题: used话题: size话题: dimension