You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#942 was closed, and I cannot re-open it (because I do not have permissions), but it's still broken:
#include<algorithm>
#include<chrono>
#include<functional>
#include<iostream>
#include<thread>
#include<vector>intmain() {
std::vector<std::unique_ptr<std::size_t>> numbers(1024 * 1024 * 100);
std::vector<std::thread> threads(1);
std::atomic<std::size_t> index{};
auto start = std::chrono::system_clock::now();
for (auto& thread : threads) {
thread = std::thread{[&index, &numbers]() {
while (true) {
auto i = index.fetch_add(1, std::memory_order_relaxed);
if (i >= numbers.size()) return;
numbers[i] = std::make_unique<std::size_t>(i);
}
}};
}
for (auto& thread : threads) thread.join();
auto end = std::chrono::system_clock::now();
auto duration =
std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
std::cout << "Running on " << threads.size() << " threads took " << duration
<< std::endl;
}
Compiling this on macOS, like this:
c++ -std=c++20 -g -Wall -Wextra -L/Users/martijn/test -lmimalloc -o allocate allocate.cpp
leads to the following output when run:
allocate(16926,0x16d067000) malloc: *** error for object 0x3ff8c010020: pointer being freed was not allocated
allocate(16926,0x16d067000) malloc: *** set a breakpoint in malloc_error_break to debug
The text was updated successfully, but these errors were encountered:
#942 was closed, and I cannot re-open it (because I do not have permissions), but it's still broken:
Compiling this on macOS, like this:
c++ -std=c++20 -g -Wall -Wextra -L/Users/martijn/test -lmimalloc -o allocate allocate.cpp
leads to the following output when run:
The text was updated successfully, but these errors were encountered: