473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

new TCHAR[..] and access violation

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
3 3120
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Steven Reddie | last post by:
I understand that access violations aren't part of the standard C++ exception handling support. On Windows, a particular MSVC compiler option enables Microsoft's Structured Exception Handling...
7
by: ree | last post by:
I need to use a function from a wininet library, it requires the use of const TCHAR. The problem is the value needs to be calculated, so at the end I have this string but I am having troubles...
0
by: Steven Reddie | last post by:
In article <slrnbnj19j.av.juergen@monocerus.manannan.org>, Juergen Heinzl wrote: >In article <f93791bd.0309282133.650da850@posting.google.com>, Steven Reddie wrote: >> I understand that access...
4
by: sorty | last post by:
Hi, I have read in many places that TCHAR can be 'char' or 'wchar_t' depending on ANSI or UNICODE. I have also read that LPTSTR is a long pointer to a TCHAR. I am confused about the...
0
by: Microsoft News | last post by:
I'm getting the following error when I shut down my C# .NET v1.1 application: 0xC0000005: Access violation reading location 0x73bc0000 This error didn't occur until I added a...
2
by: Boris Fortes | last post by:
I need to unhook event receiver as result of native C++ event. It unhooks successfully, but __raise does not return and throws access violation. Visual Studio 2003 How to reproduce: Consol...
2
by: SteveK | last post by:
I cannot for the life of me figure out how to TCHAR to be defined as an unsigned char as it is in out 6.0 project. I created a fresh VS 2003 project and played around with the settings and still...
2
by: =?Utf-8?B?c29jYXRvYQ==?= | last post by:
Hi, I have a DLL in VC6, when a specific function is called it will spawns a few threads and then return. The threads stay running and inside one of these threads an event is created using the...
39
by: Martin | last post by:
I have an intranet-only site running in Windows XPPro, IIS 5.1, PHP 5.2.5. I have not used or changed this site for several months - the last time I worked with it, all was well. When I tried it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.