473,324 Members | 2,400 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,324 software developers and data experts.

how to solve this problem?

I have a piece of code:

....
std::vector< double > vProcessedSpectrum;
vProcessedSpectrum.resize( 1 );
vProcessedSpectrum.resize( 10 );
vProcessedSpectrum.resize( 102 );
vProcessedSpectrum.resize( 1024 ); //error happened here!
....

When I resize the vector to some big number, I got error:
"Debug Error" and break into the "ctr0msg.c".

How to fix the problem?

Jun 7 '06 #1
8 1545
kathy wrote:
I have a piece of code:

...
std::vector< double > vProcessedSpectrum;
vProcessedSpectrum.resize( 1 );
vProcessedSpectrum.resize( 10 );
vProcessedSpectrum.resize( 102 );
vProcessedSpectrum.resize( 1024 ); //error happened here!
...

When I resize the vector to some big number, I got error:
"Debug Error" and break into the "ctr0msg.c".

How to fix the problem?


Please provide a minimal, but complete program that demonstrates the
problem.

Jun 7 '06 #2

Rolf Magnus wrote:
Please provide a minimal, but complete program that demonstrates the
problem.


There are a lot of fuction / object call. Just put the object there
might not helpful

Jun 7 '06 #3
kathy wrote:
Rolf Magnus wrote:
Please provide a minimal, but complete program that demonstrates the
problem.


There are a lot of fuction / object call. Just put the object there
might not helpful


He means that you should try to reduce your program to something short
but *complete* that demonstrates the problem you are describing.

Cheers! --M

Jun 7 '06 #4
>Then it's likely that the error came from the code you got rid of and not
the code you posted, in which case nobody can help you.
You should try to reduce your code in small steps. As soon as it starts
working, the part that you removed last is likely to contain the error.


question is:

If I moved out the error line, every thing works fine. If I add it, it
cause the error:

....
Processed_Spectrum.resize(452);//error here, but
Processed_Spectrum.resize(451) ok
....

It looks like somewhere memory leaking. But I try to stop some
processes and rerun mine. I still get error - always error at
resize(452). I expected error happened at somewhere > 452.

Jun 7 '06 #5

mlimber wrote:
kathy wrote:
Rolf Magnus wrote:
Please provide a minimal, but complete program that demonstrates the
problem.


There are a lot of fuction / object call. Just put the object there
might not helpful


He means that you should try to reduce your program to something short
but *complete* that demonstrates the problem you are describing.

Cheers! --M


I know. But if I get rid of other code with only the posted code there.
It works fine.
I do not know where the problem come from.

Jun 7 '06 #6
kathy wrote:
...
Processed_Spectrum.resize(452);//error here, but
Processed_Spectrum.resize(451) ok
...

It looks like somewhere memory leaking. But I try to stop some
processes and rerun mine. I still get error - always error at
resize(452). I expected error happened at somewhere > 452.


Your program corrupted memory before these lines. The corruption remained
hidden until these lines discovered it.

You need to remove _all_ your program, in big chunks, to see which chunk
contains that corruption. Or you can inspect the high-risk areas manually,
or use a tool like Purify or Valgrind.

--
Phlip
Jun 7 '06 #7
kathy wrote:

mlimber wrote:
kathy wrote:
> Rolf Magnus wrote:
> > Please provide a minimal, but complete program that demonstrates the
> > problem.
>
> There are a lot of fuction / object call. Just put the object there
> might not helpful
He means that you should try to reduce your program to something short
but *complete* that demonstrates the problem you are describing.

Cheers! --M


I know. But if I get rid of other code with only the posted code there.
It works fine.


Then it's likely that the error came from the code you got rid of and not
the code you posted, in which case nobody can help you.
You should try to reduce your code in small steps. As soon as it starts
working, the part that you removed last is likely to contain the error.
I do not know where the problem come from.


Neither does anyone else here.

Jun 7 '06 #8

"kathy" <yq*****@yahoo.com> wrote in message
news:11*********************@f6g2000cwb.googlegrou ps.com...
Then it's likely that the error came from the code you got rid of and not
the code you posted, in which case nobody can help you.
You should try to reduce your code in small steps. As soon as it starts
working, the part that you removed last is likely to contain the error.


question is:

If I moved out the error line, every thing works fine. If I add it, it
cause the error:

...
Processed_Spectrum.resize(452);//error here, but
Processed_Spectrum.resize(451) ok
...

It looks like somewhere memory leaking. But I try to stop some
processes and rerun mine. I still get error - always error at
resize(452). I expected error happened at somewhere > 452.


Are you saying that you get an error any time you pass a number that is 452
or higher to resize()? Or, do you mean that you're actually calling resize
multiple times, but it's crashing after several calls to resize()?

The code you have shown does not appear to have a problem. That is why it
has been suggested that you look at other code, which gets executed _before_
the one that you've shown. Something earlier may be trashing memory, and it
only shows up when you try to resize with a larger value.

-Howard


Jun 8 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BVM | last post by:
Hi, All: I have this error. It seems execution time is too long. Actually the execution time is about 30 seconds(I tested in Query analyzer). How do I solve this problem? ...
3
by: Alex | last post by:
Hi, I have a problem involving some design issue. I have two unrelated (that is, they do not derive from the same base) classes: ClassA ClassB Both have a quite similar interface, so they can...
7
by: Shapper | last post by:
Hello, I have an ASP:ImageButton where I want to call a function and pass a string: OnClick="Change_Photo("John")" I am having problems with "". I tried
6
by: Federico | last post by:
Hi, this is what I can do: - Create new solutions using VS.Net ASP.Net - Save the solutions, build the solution, view in browser with the solution still open. But, once I close the solution, I...
0
by: Jitesh | last post by:
I am facing a problem in webservice, I want to know what will be the exact procedure to solve the problem............. What I want to do............ I have a table named order in SQL Server....
27
by: John Salerno | last post by:
Ok, here's a problem I've sort of assigned to myself for fun, but it's turning out to be quite a pain to wrap my mind around. It's from a puzzle game. It will help if you look at this image: ...
8
by: vj | last post by:
Hi all, I want to solve the two equations u*tan(u)=w and u^2 + w^2=V^2, where V is a known constant, and u and w are the two unknowns to be determined. Please can someone suggest me how to...
1
by: arun | last post by:
Query is too complex -------------------------------------------------------------------------------- Hi, I was trying to solve this problem since last two days but couldn't find any solution. ...
17
by: Michael Reichenbach | last post by:
Here is the example code. int main(int argc, char *argv) { string Result; WIN32_FIND_DATA daten; HANDLE h = FindFirstFile(TEXT("c://test"), &daten); system("PAUSE"); return EXIT_SUCCESS; }
2
by: itsvineeth209 | last post by:
My task is to create login control without using login control in tools. I shouldnt use sqldatasource or any other. I should use only data sets, data adapters and data readers etc. U had created...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.