You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Sindhi Sindhi <si...@gmail.com> on 2013/05/17 13:15:31 UTC

Apache module memory allocations

Hi,

I have written a C++ Apache module, and I have three questions related to
it, kindly advice.

1. How do I increase the memory for httpd.exe? As in, I have a C++ module
that does a lot of initializations, reading huge XML files
and storing this huge data in memory till the server is running. So I'm
frequently seeing crashes in the release mode of my module
(MyFilter.dll). These crashes indicate the following -
Unhandled exception..... Access violation writing location
0x0000000000000020
Unhandled exception..... Access violation reading location
0x0000000000000018
Unhandled exception..... A heap has been corrupted

I guess these exceptions are due to memory issues. I re-checked and the C++
module I have does delete all allocated memory on time. So the only reason
I can guess is that httpd.exe is not getting sufficient memory for the
allocations made in my C++ module. Please correct me if I'm wrong. So how
do I increase the memory that can be used by httpd.exe?

2. If I need to allocate memory in the C++ module I have written, should I
always use apr_pcalloc(apr_pool_t* p, size) only to allocate memory?
OR
Can I use the standard new/malloc in the C++ module and release it using
delete/free?
As of now I'm using "new()" and "delete()" to allocate and deallocate.
Could this be the reason for the above crashes?

3. I've registered a callback function/filter that will be called whenever
a browser makes a request. I have surrounded this callback function within
try-catch blocks in the C++ module. But when httpd.exe crashes with the
above exceptions mentioned in item1 above, the control does not go to the
catch block in the callback function, it rather crashes the httpd.exe
server. I will not want the httpd.exe server to crash due to a bug in the
C++ module I have written. Kindly advice how to handle this.

Thanks.