472,779 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

Large swap allocation bug

Hi,

I am trying to execute some code compiled by g++ on Linux and have
found that after some time, the program allocates a huge amount of
swap space (250MB on my machine which has 512MB physical) and (700MB
on another server with 1GB physical RAM).

I have used vmstat to trend the amount of swap and observed that the
memory is not being "thrashed" and there is simply a large amount of
data that has been swapped out. This still slows down my PC and is
therefore a big problem.

There don't appear to be any memory leaks (I've checked the run-time
performance using mpatrol), and the amount of swqp does not increase
linearly, rather it is a single large step.

The algorithm that my code executes is a clustering algorithm that
iteratively clusters a data set using an increasing number of clusters
(these are a class CCluster that I have written to implement the
algorithm) so it makes sense that over time the program would use
slightly more memory - but not the instantaneous leap that I am
observing.

Has anybody seen this sort of behaviour before? Can anybody suggest
where I should begin looking for a bug?

Cheers,
Rob
Jul 22 '05 #1
1 1567
Robert May wrote:
Hi,

I am trying to execute some code compiled by g++ on Linux and have
found that after some time, the program allocates a huge amount of
swap space (250MB on my machine which has 512MB physical) and (700MB
on another server with 1GB physical RAM).

I have used vmstat to trend the amount of swap and observed that the
memory is not being "thrashed" and there is simply a large amount of
data that has been swapped out. This still slows down my PC and is
therefore a big problem.

There don't appear to be any memory leaks (I've checked the run-time
performance using mpatrol), and the amount of swqp does not increase
linearly, rather it is a single large step.

The algorithm that my code executes is a clustering algorithm that
iteratively clusters a data set using an increasing number of clusters
(these are a class CCluster that I have written to implement the
algorithm) so it makes sense that over time the program would use
slightly more memory - but not the instantaneous leap that I am
observing.

Has anybody seen this sort of behaviour before? Can anybody suggest
where I should begin looking for a bug?


1) This is off topic for c.l.c++, as it's not even remotely a question
about the C++ language.

2) If I understand you correctly, it's likely that the problem is not so
much a *bug* as an unfortunate interaction with the underlying allocator
on your system (nothing wrong with the allocator, it just sounds like
you've hit a pessimal case). It goes something like this:

You allocate a chunk of N bytes.
You free that chunk of N bytes (which are now available for further
allocation).
You allocate a chunk of N + m bytes (so those orginal N bytes are
useless; that chunk is too small).
You free that chunk of N + m bytes (...)
You allocate a chunk of N + m + l bytes...

I guess you get the picture... ;-)

Most likely the best solution would be to use placement new -- i.e.
custom allocation.

HTH,
--ag

--
Artie Gold -- Austin, Texas

"If you don't think it matters, you're not paying attention."
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Otto Meijer | last post by:
Hi everyone, for one of my projects I need to figure out the size of the swap file(s) of a certain system. The problem is I need to do this on a host of platforms like: HP_UX, Solaris, Linux,...
3
by: Akyl Tulegenov | last post by:
Dear All! I've got a question which is rather system specific case. Suppose I am dealing with a large array of ~4Gig of entities. The question is : what is faster , to address it through a...
3
by: Wayne Marsh | last post by:
Hi all. I am working on an audio application which needs reasonably fast access to large amounts of data. For example, the program may load a 120 second stereo sound sample stored at 4bytes per...
7
by: mef526 | last post by:
I have had this problem for months now and it has been nagging me. I have a large project that has several C++ DLL's, one of them uses malloc / calloc / free for the other DLL's. I process very...
57
by: Chris Foote | last post by:
Hi all. I have the need to store a large (10M) number of keys in a hash table, based on a tuple of (long_integer, integer). The standard python dictionary works well for small numbers of keys,...
7
by: Marcus Kwok | last post by:
I am utilizing a std::vector<int>, but due to a platform-specific reason (Managed C++, but this is irrelevant), in order to include it as a member of a class, I have to work with a pointer to it. ...
1
by: Jonathan Wilson | last post by:
I am working on some software which has to deal with data that could be as large as 500mb or so. Currently I am using new and delete to manage this memory but I find it is not ideal and sometimes...
8
by: theCancerus | last post by:
Hi All, I am not sure if this is the right place to ask this question but i am very sure you may have faced this problem, i have already found some post related to this but not the answer i am...
4
by: =?Utf-8?B?U2VyZ2Vp?= | last post by:
Dear staff Can I get your assistance with \3GB (LARGEADDRESSAWARE) switch in mixed mode process built by VS 2008, please? I have a mixed mode application: C# GUI calling native C++ DLL through...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.