内存分配问题?
我正在unix服务器中执行Proc代码,proc将从文件中读取记录并将数据存储在结构数组中,经过一些处理后它将产生输出。当我从文件中读取 368700 条记录并在代码中进行处理时,意味着它执行良好。但是当我尝试从文件和进程中读取 370000 条记录时,我收到一条错误消息 ORA-12533: TNS:illegal ADDRESS 参数和非法地址
。此错误的原因和可能的解决方案可能是什么?
我已经完成了如下的内存分配:
int unsigned long size=(atoi(argv[2]))+1;
printf("\nthe size is %lu",size);
printf("\n am here 1");
what_if_var =(what_if*)malloc((size)*sizeof(what_if));
temp_var =(what_if*)malloc((size)*sizeof(what_if));
I am executing Proc code in unix server, the proc will read the record from file and store the data in array of structure and after some processing it will produce the output. When i read 368700 records from the file and process in the code means its executing fine. but when i try to read 370000 records from the file and process means, I am getting an error saying ORA-12533: TNS:illegal ADDRESS parameters and illegal address
. What could be the cause and possible solution for this error?
I've done memory allocation like below:
int unsigned long size=(atoi(argv[2]))+1;
printf("\nthe size is %lu",size);
printf("\n am here 1");
what_if_var =(what_if*)malloc((size)*sizeof(what_if));
temp_var =(what_if*)malloc((size)*sizeof(what_if));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
malloc() 的返回值C 语言中的
。malloc()
调用中写入sizeof *what_if_var
,以防what_if_var
的类型实际上不是what_if
。malloc()
in C.sizeof *what_if_var
in the call tomalloc()
, in case the type ofwhat_if_var
isn't reallywhat_if
.NULL
pointer back, in case of low memory allocations can fail.size_t
to hold sizes, it's the type ofmalloc()
's argument so it makes sense.您应该检查 malloc 是否返回 NULL,这意味着没有可用内存可供分配。您应该使用函数 free() 释放不再使用的数据的内存。
内存限制取决于操作系统及其配置。 32 位进程的内存限制可能是 2 GB 或 4 GB。
You should check if malloc returned NULL, it means that there is not available memory to be allocated. You should free the memory with data that you will not use again with the function free().
The memory limit depends of the operating system and its configuration. The limit of memory of a 32-bit process may be 2 GB or 4 GB.