Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Probably, the thing that Parallel Studio is complaining about is that you exposed the basic file operations (open, close, read) to any user of your class, making your <code>Example</code> class little more than a somewhat gimped wrapper around <code>std::fstream</code> with a little bit of data validation. In particular, you're not enforcing that users of <code>Example</code> call <code>open</code> and <code>close</code> in the right manner.</p> <p>This doesn't bother valgrind because it's a very different tool. Valgrind watches your program as it runs to make sure that it doesn't happen to do anything stupid like leak memory or kernel resources, which presumably it doesn't. PS is doing some kind of static analysis to see if you made it <i>possible</i> to leak resources, which in this case you did (even though you don't then go on to actually exploit this possibility).</p> <p>I would rewrite this class to be more C++ish. In particular, <code>open_file()</code> should be a constructor, not a method that could be called at any time. <code>close_file()</code> should equivalently be the destructor, rather than just some random method. This should satisfy Parallel Studio that kernel resources can't (usually) be leaked, unless the object itself is leaked (which it would presumably catch the possibility of someplace else, but in any case if the entire object is leaked, it's not your class's fault).</p> <p>Not sure what PS is complaining about on the memory leak; that line looks fine to me. Unless there's something non-obvious about <code>std::stringstream</code> that I've forgotten.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload