0

我在 unix 服务器中执行 Proc 代码,proc 将从文件中读取记录并将数据存储在结构数组中,经过一些处理后会产生输出。当我从文件中读取 368700 条记录时,代码中的进程意味着它的执行良好。但是当我尝试从文件和进程中读取 370000 条记录时,我收到一条错误消息ORA-12533: TNS:illegal ADDRESS parameters and 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));
4

2 回答 2

1
  1. Don't cast the return value of malloc() in C.
  2. It's better to write sizeof *what_if_var in the call to malloc(), in case the type of what_if_var isn't really what_if.
  3. Always check that you didn't get a NULL pointer back, in case of low memory allocations can fail.
  4. Investigate if there perhaps is a limit to how much RAM a process can use, some sysadmins do this on shared machines.
  5. Use size_t to hold sizes, it's the type of malloc()'s argument so it makes sense.
于 2011-05-13T08:19:33.550 回答
0

您应该检查 malloc 是否返回 NULL,这意味着没有可用的内存要分配。您应该使用 free() 函数释放不再使用的数据来释放内存。

内存限制取决于操作系统及其配置。32 位进程的内存限制可能是 2 GB 或 4 GB。

于 2011-05-13T20:44:24.970 回答