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 に答える