G ++ inexplicable error: malloc (): memory upload uption (fast)

Source: Internet
Author: User

I wrote a program with g ++, and one of them is

For (I = 0; I <5; I ++)

Push_back ();

This code has been called N times. When it is called for a certain number of times, the above error is reported when it is executed to push_back. Use gdb to read it one by one and finally enter malloc. c. the following error is returned:

Malloc. c: 3096: sYSMALLOc: Assertion '(old_top = (mbinptr) (char *) & (av)-> bins [(1)-1) * 2])-_ builtin_offsetof (struct malloc_chunk, fd) & old_size = 0) | (unsigned long) (old_size)> = (unsigned long) (_ builtin_offsetof (struct malloc_chunk, fd_nextsize) + (2 * (sizeof (size_t)-1 ))&~ (2 * (sizeof (size_t)-1) & (old_top)-> size & 0x1) & (unsigned long) old_end & pagemask) = 0) 'failed.
Aborted

 

Initially, it was suspected that the memory was leaking. on the Internet, it was said that the heap space was insufficient.


Debugging for half a day, no result, it is best to compare with the previous program, find the cause of the error in


I like to disable memory alignment when defining struct.

# Pramga pack (push, 1)

... Define struct

# Pargma pack (pop) // you have forgotten this sentence


The next thing happened.

From ma100's column
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.