- 0
Help with 2D Vector Memory Errors
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By wrack · Posted
This is weird. Mythos is more unrestricted compared to Fable. Technically it poses more risk!! -
By sava700 · Posted
This is a great thing, I always have issues with Verizon while inside of certain football stadiums due to the saturation and walls blocking signal so a LOS way to connect would be great. Verizon was supposed to be offering sat data this year but I've not heard a word of it lately. Dude is sending rockets into space in a cheap manner, low waste foot print and has a great product with solar/battery tech. We would be so far behind China right now if not for him and a push to get back into space. -
By sava700 · Posted
illegally? Proof of that? Seems you are posting misinformation or well a pure straight up lie cause there is zero proof of such a thing. But I get it... -
-
By Copernic · Posted
KillerPDF 1.6.0 by Razvan Serea KillerPDF is a lightweight, portable PDF editor for Windows built for users who want full control without subscriptions, installers, or telemetry. It runs as a single executable, making it ideal for USB use and field work. You can view PDFs with smooth PDFium rendering, navigate quickly with thumbnails, zoom, and shortcuts, and reorganize pages using drag-and-drop. It supports merging multiple PDFs, splitting documents, and extracting selected pages. KillerPDF also allows inline text editing with font matching to preserve the original layout, plus annotations like text boxes, freehand drawing, highlights, and reusable signatures. You can search full text, copy content easily, and print documents with flattened annotations. Designed as a free and open alternative to bloated PDF tools, it works fully offline on Windows 10/11 x64. No runtimes install. Everything needed is inside the EXE (targets .NET Framework 4.8, which ships with every supported Windows release). KillerPDF key features: High-quality PDF rendering via PDFium Edit PDF text inline (double-click to modify text) Page thumbnails and fast navigation with zoom and shortcuts Merge multiple PDFs into one Split PDFs and extract selected pages Drag-and-drop page reordering Font matching to preserve original document appearance Text boxes for notes Freehand drawing tools Highlight overlays with adjustable color, size, opacity Undo actions and clear per-page annotations Create, draw, and save reusable signatures Click-to-place signatures anywhere Full-text search with highlighted results Drag-select or Ctrl+A to copy text Print with annotations flattened Portable single-file app (~15 MB) No installer, no admin rights required No account, no telemetry KillerPDF 1.6.0 changelog: A big release: major new features, a full visual refresh, and an internal rewrite. New Tabbed documents - open several PDFs at once, each restoring its page, zoom, and view OCR built into the exe (Tesseract) - OCR a page or dragged region to the clipboard, make a scan searchable, or extract all text; extra languages download on demand Digital signatures with a cloud certificate (Certum SimplySign), reusable signatures, and click-to-sign form fields Transform tool - rotate, scale, flip, and straighten a crooked scan, with live preview Edit existing text by double-clicking a line (the original is cleanly covered) Line tool, refreshed draw/highlight bars, resizable word-wrapping text boxes, and a full RGB color picker with eyedropper Print options (scale, position, margins, two-sided), page-number stamping, folder/.zip import, Document Info (F12), and recent files with file-type icons Translations: Bengali, Turkish, Simplified Chinese, German, French. Changed New logo, icons, fonts, and colors throughout Six themes with per-theme accent colors; sidebar docks left or right; toolbar style picker Internal rewrite: the ~15,000-line main window split into ~40 focused files (no behavior change) Fixed True 300 DPI printing, encrypted/damaged PDFs open on a background thread with a repair fallback, form fields render in every view mode, and undo is one item per press Download: KillerPDF 1.6.0 | 14.6 MB (Open Source) Link: KillerPDF Home Page | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
-
-
Recent Achievements
-
flexorcist earned a badge
Week One Done
-
Woland13 earned a badge
One Month Later
-
Woland13 earned a badge
Week One Done
-
bernmeister earned a badge
One Year In
-
Scoobystu earned a badge
Week One Done
-
-
Popular Contributors
-
Tell a friend
Question
Omega037
I have been having a serious problem relating to memory allocation and arrays/vectors in C++ using the G++ compilier on both a windows machine(Dev-C++) and linux(debian). I would post all the code, but it is proprietary technology(I'm a Graduate Student) and therefore I can't share it openly without permission.
That said, the part of the code that is having a problem is not the proprietary part, so I will give a redacted version of what I am doing and explain the error I am getting.
Basically, the program has 2 classes, which we will Trainer and Runner. The main function merely calls an instance of Trainer once with certain parameters, which in turn calls one instance of Runner with certain parameters.
The redacted header files for each look something like this:
#include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> #include <string.h> #include <time.h> #include <math.h> #include <vector> using namespace std; class Runner { private: int num_gates; int num_models; int num_trainings; int total; vector< vector<float> > training_data; //array of training pairs public: Runner(); Runner(int n_gates, int n_models, int n_trainings, char *train_file); //constructor ~Runner(); //destructor float compute_output(); vector< vector<float> > load_training_data(); //loads training data void setsigmas(vector<float> sig);#include "Runner.h" class Trainer { private: vector<vector<float> > sig_data; int population_size; int num_generations; //number of generations Runner g; int num_trainings; //number of training pairs int num_gates; //number of gate variables int num_models; //number of models void save_pop(); vector<vector<float> > load_pop(); vector<float> mutcross_sig; void mutcross();Basically, each class has a 2D Vector which holds training set data and paramter data respectively. These do not change in size once filled, and the training data never changes once loaded.
Here is the constructor and load data for the Runner class:
#include "Runner.h" Runner::Runner(){ } Runner::Runner(int n_gates, int n_models, int n_trainings){ num_gates = n_gates; num_models = n_models; num_trainings = n_trainings; total = n_gates + n_models + 1; try{ training_data = vector<vector<float> >(n_trainings, vector<float> (total) ); } catch (bad_alloc) { cout << "PROBLEM"; } training_data = load_training_data(); } vector<vector<float> > Runner::load_training_data() { ifstream c("test1.txt"); float abc; vector< vector<float> > t_data; vector<float> def; for(int i = 0; i < num_trainings; i++){ for(int j = 0; j < total; j++){ c >> abc; def.push_back(abc); } t_data.push_back(def); def.clear(); } return t_data; }This is the constructor and load data for the Trainer class:
#include "Trainer.h" Trainer::Trainer(int pop_size, int num_gen, int n_trainings, int n_gates, int n_models){ total = n_gates +1; float t_sig[total-1]; top=1000; char savefile[40]; float holdB; int nogo=0; //set the parameters population_size = pop_size; num_generations = num_gen; num_trainings = n_trainings; num_gates = n_gates; num_models = n_models; cout <<"Save To Filename" << endl; cin >> savefile; pop.open(savefile); gen_report.open("abctre4.txt"); g = Runner(num_gates, num_models, num_trainings); int load=0; cout << "Load Data? (1=YES, 0=NO)"; cin >> load; if(load == 1){ sig_data = load_pop(); gen_best=0; gen_avg=0; } else{ for(int t=0;t<pop_size;t++){ sig_data.push_back(vector<float>()); } for(int y=0; y < pop_size; y++){ for(int j=0; j < num_gates; j++){ holdB=random(min_value, max_value); try{ sig_data[y].push_back(holdB); } catch(bad_alloc){ cout << " MEMLIMIT "; try{ sig_data[y].push_back(holdB); } catch(bad_alloc){ cout << " MEMLIMIT_AGAIN "; nogo=1; } } t_sig[j]=holdB; } g.setsigmas(t_sig); holdB=g.crossvalidation_run(0); sig_data[y].push_back(holdB); if(holdB <= top){ gen_best = y; top = holdB; } if(nogo == 0){ gen_avg = gen_avg + holdB; } else{ gen_avg = gen_avg + (gen_avg/y+1); nogo = 0; } } } for(int x=0; x < num_gates; x++){ try{ mutcross_sig.push_back(0); } catch(bad_alloc){ cout << " MUTMEMLIMIT "; try{ mutcross_sig.push_back(0); } catch(bad_alloc){ cout << " MUTMEMLIMIT_AGAIN "; } } } } /***************************************************************/ vector<vector<float> > Trainer::load_pop() { char loadfile[40]; cout <<"Load From Filename" << endl; cin >> loadfile; ifstream inpop(loadfile); float abc; vector< vector<float> > s_data; vector<float> indef; for(int i = 0; i < population_size; i++){ for(int j = 0; j < total; j++){ inpop >> abc; indef.push_back(abc); } s_data.push_back(indef); indef.clear(); } inpop.close(); return s_data; }The Trainer then goes through iterations of setting certain paramters in the Runner and running it, then mutating the parameters based on the output from that process.
Unfortunately, regardless of if I try to load the data from a file or randomly generate it, it will often fire off bad allocation errors or crash the program altogether. The same thing happens if I use float ** and "new" to create the 2D Vectors. Any ideas?
Link to comment
https://www.neowin.net/forum/topic/734718-help-with-2d-vector-memory-errors/Share on other sites
0 answers to this question
Recommended Posts