By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,442 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

new TCHAR[..] and access violation

P: n/a
sometimes a simple line code like

TCHAR *tRow = new TCHAR[tempSize];
cause an access violation.

What's problem?

My application is multithread, compiled in visual studio 7.0, unmanaged.

thanks for help

bye

Alek
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Alek wrote:
sometimes a simple line code like

TCHAR *tRow = new TCHAR[tempSize];
cause an access violation.

What's problem?


The problem is, very likely, that your application has corrupted the heap by
over-indexing a heap allocation, or by modifying memory after you've
returned it to the heap (via delete or free).

The problem lies somewhere in your program - likely far away from the line
where the error is detected.

You might have better luck isolating the problem by running your application
under the full page heap. You can enable full-page heap for your
application by downloading & installing the latest Windows debuggers from

http://www.microsoft.com/whdc/ddk/de...g/default.mspx

and issue the command

c:\debuggers>gflags -i your_app.exe +hpa

from a command prompt (assuming you installed the debuggers into
c:\debuggers).

Note that the full-page heap won't detect all errors, because the VC++ CRT
does some of it's own heap management (holding onto larger blocks allocated
from the system heap and sub-allocating from those blocks).

-cd
Nov 16 '05 #2

P: n/a
good, but when I set

gflags -i your_app.exe +hpa

how can I see heap status ? where is it logged ?

thank you
bye

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:ux*************@tk2msftngp13.phx.gbl...
Alek wrote:
sometimes a simple line code like

TCHAR *tRow = new TCHAR[tempSize];
cause an access violation.

What's problem?
The problem is, very likely, that your application has corrupted the heap

by over-indexing a heap allocation, or by modifying memory after you've
returned it to the heap (via delete or free).

The problem lies somewhere in your program - likely far away from the line
where the error is detected.

You might have better luck isolating the problem by running your application under the full page heap. You can enable full-page heap for your
application by downloading & installing the latest Windows debuggers from

http://www.microsoft.com/whdc/ddk/de...g/default.mspx

and issue the command

c:\debuggers>gflags -i your_app.exe +hpa

from a command prompt (assuming you installed the debuggers into
c:\debuggers).

Note that the full-page heap won't detect all errors, because the VC++ CRT
does some of it's own heap management (holding onto larger blocks allocated from the system heap and sub-allocating from those blocks).

-cd

Nov 16 '05 #3

P: n/a
Alek wrote:
good, but when I set

gflags -i your_app.exe +hpa

how can I see heap status ? where is it logged ?


Run you app under a debugger and you'll see messages from the heap manager
(in the Output window is you're using Visual Studio).

-cd
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.