Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7941913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:48:35+00:00 2026-06-03T23:48:35+00:00

My code seems to work(I haven’t tried it with large datasets because of the

  • 0

My code seems to work(I haven’t tried it with large datasets because of the above error).

Code:

#include <iostream>
#include <queue>
#include <stxxl/queue>

int main()
{
   //queue<int> q; //this works
   stxxl::queue<int> q; //does not work
   for (int i = 0; i<100; i++) {
       q.push(i);
   }
   std::cout << "done copying" << std::endl;
   while (q.empty() == false) {
       std::cout << q.front() << std::endl;
       q.pop();
   }
   std::cout << "done poping" << std::endl;
   return 0;
}

my simple .stxxl is simply: disk=./testfile,0,syscall

But my error is:

stackexchangeexample(3884) malloc: *** error for object 0x101c04000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
The program has unexpectedly finished.

I’m not sure how to troubleshoot it, do I need to free memory in this case? I’m still learning c++ so sorry if this is really basic(this only happens when I use the stxxl queue).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:48:37+00:00Added an answer on June 3, 2026 at 11:48 pm

    I’ve never used stxxl before but since it’s a template you can take a look at the code here: http://algo2.iti.kit.edu/stxxl/trunk/queue_8h_source.html. And since you’re a newbie I’ll explain a few things. This goofy queue maintains a queue of pointers. Line 00054 shows typedef ValTp value_type, so now your int is a value_type. Line’s 00072 & 00073 show that your front and back elements are of that value_type. Do you see how they will be maintained as pointers. Finally if you look at any constructor the pool_type* pool defined on line 00069 will be “new’d” up (which is the basis of your elements) and the init function is always called. And within init, pool->steal() is called, click on it if you want to learn more.

    In short, you need to be pushing new’d up integers onto your queue. Bad interface, not your fault.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code seems to work well, modifying the properties of my button, except the
Hey guys, the following snippet of jQuery code seems to work fine in Google
The following code seems not to work, even though the file appears to be
The below code seems like it should work; however, the blob in the database
Is the following always acceptable code? It seems to work, but does it consistently
Subtitle: why does this code work? It seems to allow comparison of NSNumber with
My Jquery code doesn't seem to work in IE8 when adding a doctype above
This code only seems to work in Firefox. Safari and Opera don't like it:
Ok, so i tried multiple of solutions but nothing seems to work for me,
I've tried searching around for an answer, but haven't found one that seems to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.