Programming :: Make Objects Created With New Garbage-collected
Apr 30, 2011
I read this guide: [URL].. but I still don't understand how to make objects created with new garbage-collected. Could someone explain how or find a link to an explanation?
View 13 Replies
ADVERTISEMENT
Aug 31, 2010
I am trying to make a hash of objects in perl (long story.) I have a package containing the main hash and all the subroutines necessary to work with it. My "new" subroutine used to add an object to the hash goes like this:
Code:
$tmpdir="/tmp";
$subdir="/AutoScript";
[code]...
View 14 Replies
View Related
Jan 7, 2010
I was wondering if it is possible to have a garbage collector in C, and would it be too difficult to create?
View 1 Replies
View Related
Mar 4, 2010
Code:
char retBuffer[100];
recv(sock , retBuffer ,sizeof(retBuffer) , 0);
if i send a string smaller then my buffer size retBuffer always have garbage of the end of it....what can i do to eliminate tis problem ?
View 2 Replies
View Related
Aug 27, 2009
I'm interested in writing a generational garbage collector in C++. This is for a Python-like programming language project. I have used Boehm's garbage collector before, but I'm worried that it will have noticeable pause times (unacceptable for interactive programs). Since I can't really find any other C++ established GCs out there, I have been thinking of simply writing my own.
However, there are two essential ingredients I need for this:
- Some kind of write barrier mechanism that will notify my collector when something is written to a part of the heap
- A way for me to know the addresses and sizes of the stack, heap and global storage (the root sets)
how to implement write barriers (and how to get the stack, heap and global storage information) on the Linux platform? As an alternative, if you know of C++ GCs other than Boehm, I would also be interested.
View 14 Replies
View Related
Feb 9, 2011
I actually have two reasons for posting this. One is to see if there's an actual name for characters like this:Hopefully that will show up correctly for you. If not, it's a little box with four numbers in it, one in each corner. I don't know their name or their reason for showing up, so it's hard to look for help.
My main problem, though, is that I wrote a program that prints some output to a console using ncurses as it runs. These characters show up on the console, seemingly at random, and disturb the whole thing. Sometimes I'll also get sets of characters like "[13;" I'm not printing anything bizarre on there, just strings and floating-point numbers.
View 6 Replies
View Related
Jul 21, 2010
The code below prints garbage if I use puts() but it is fine if I use printf() instead (see sample of output at the bottom of this post). The odd thing is that the mess always starts after exactly eight properly printed characters. That sort of regularity can't be a coincidence, can it? It almost looks like an encoding issue (I'm using UTF-8) but if it really is, then I don't understand why the printf() is unaffected.
Code:
#include <stdio.h>
#include <string.h>
const char *nChars (const char *, int);
int main (int argc, char * argv[]){
char * name ="Count Dracula++";
int len = strlen(name);
if (argv[1] == 0) argv[1]="printf";
printf("--->%d characters", len); .....
View 9 Replies
View Related
Feb 9, 2011
I have it so that an Env object contains all the variables in the current scope, and the parent scope. You can also save them to variables like objects, and my idea is to use the "." operator to get values from them.
First, how do I assign to them? I currently have it that only a variable name can be assigned to, but you should be able to assign to an "obj.value" expression, too. How do I keep track of what variable to set and still be able to say it in an expression and have it evaluate to the variable?
Second, these object don't really have a "type", they're just containers that contain any values you want under any name you want. How can I, for example, define a primitive "boolean" object and have things like if statements recognize it?
View 14 Replies
View Related
Jun 27, 2011
Code:
#loop until there are no more files
while [ ${#files[@]} -gt 0 ]; do
for num in `seq 1 ${#files[@]}`; do
wurd=`tail -4 ${files[$num-1]}`
[code].....
Everything works.. but when it has to unset.. it breaks.. it doesnt give an error though.. it just jams the program.
View 7 Replies
View Related
Oct 28, 2010
I have a question about shared objects and when mapping and linking is established in the following code...Well more of a verification.
getsetx.c - shared object source code Code: unsigned long x = 0;
unsigned long getx(void)
{
return x;
}
[Code].....
Now its my understanding when I execute ./testit, getsetx.so will get mapped into its address space at start up and testit will link any functions as they are needed..
View 3 Replies
View Related
Apr 6, 2011
I have two classes, for argument's sake A and B. A implements the core functionality, B is an encapsulated data structure. If you imagine this situation
[code]...
From within B's member functions, I would like to access the public function() in class A. This is not an inheritance issue, they are two discrete classes with radically different functionality. Class A makes an object of B.
View 5 Replies
View Related
Jun 24, 2010
I cannot get this to work
Code:
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import re
# @description "This is a describing text about the file currently documentet";
#DocC documentation prototype
[Code]...
View 4 Replies
View Related
Aug 30, 2010
The goal is to auto-update a webpage that contains links to network devices. These devices are all set to DHCP, and their hostnames are not guaranteed to stay the same, so static IPs or accessing via hostname is NOT an option.
Process: Run a script every hour or so to query devices on the local network to generate a list of responding devices by MAC address and what their current IP is (results.lst). Using a "static" MAC address list file "printers.db" as the database search "results.lst" to find specific MAC addresses. When a match is found, grab the IP from "results.lst" and update "index.html" with the new IP address. No comparison needs to be done between "results.lst" IP and "index.html" IP as I just want to overwrite whatever is there.
Here is what I have so far (using dummy data): PRINTERS.DBProduct Mac Address Printer1 00:00:00:00:00:11 Printer2 00:00:00:00:11:11 Printer3 00:00:00:11:11:11 Printer4 00:00:11:11:11:11 Printer5 00:11:11:11:11:11 Printer6 11:11:11:11:11:11 TEST.SH
Code:
#!/bin/sh
#------------------------------
# Quick Links Updater v2.0 |
# By Rob M. |
# with help from Tim F. |
#------------------------------
[code]....
View 4 Replies
View Related
Mar 21, 2011
I have created an object where I pass a string and a long value to it <in Java>, currently I am adding the values to my Object so I can then add it to a list like so:
Code:
List myList;
ImageObject io;
for(i = 0; i < 10; i++)
[code]....
This is what the object currently looks like:
Code:
public final class ImageObject<name, time>
{
public String name = "";
public long time = 0;
[code]....
View 1 Replies
View Related
Oct 4, 2010
Using: Open SUSE 11.0 64 bit, KDE 3.5.9 (release 49) and KDevelop 3.5.1. Problem: A singleton was created in subproject A, and so an object file is created in subproject A. In subproject B, I want to use that object file. We have not been able to find a way to link that object file created in subproject A with subproject B. Also, the subprojects are in different directories. We created a symbolic link to the ".h" and ".cpp" files in directory A. And the project compiles and links just fine after adding the symbolic link to the header and cpp files in subproject B. My concern is, that two objects of that singleton will be created. The whole idea of making a singleton is so that there is only one instance at a time.
View 8 Replies
View Related
Sep 26, 2010
does the assignment operator copy all the members also for structures containing STL objects strings,vectors,vectors of vectors...)? I did try it on my platform,and it works that way (copying all the fields),but i was wondering if it is a standard behavior or not.
View 2 Replies
View Related
Jun 3, 2011
I am new to Linux and I am trying to install a C program from source using Makefile. So I 've created a "hello world" program and then a Makefile to install it. Then I logged in as root and used
make install
The following error occurs:
make: execvp: /usr/bin: Permission denied
make: *** [install] Error 127
Here is the Makefile:
CC=gcc
CFLAGS=-c -Wall
PROGS = hello
INSTDIR = $(prefix)/usr/bin/
INSTMODE = 0755
INSTOWNER = root
INSTGROUP = root
all: $(PROGS)
$(PROGS): main.o
$(CC) main.o
main.o: main.c
$(CC) $(CFLAGS) main.c
install:$(PROGS)
$(INSTALL) $(INSTDIR)
$(INSTALL) $(INSTMODE) $(INSTOWNER) -o $(INSTGROUP) $(PROGS) $(INSTDIR)
clean:
rm -rf $(PROGS) *o $(PROGS)
So, where are the errors
View 3 Replies
View Related
Jul 13, 2011
I feel there's a bit of a misunderstanding going on between C++ and me...My problem is that I have a deque of pointers to a class, and create objects then add them to the deque in a for loop. However, the destructor is called on the object as soon as the loop quits.
Code:
This prints:
Code:
Now, if I change the deque from deque<Test*> to deque<Test> then it works fine - I get:
Code:
However, I can't do this with my actual code, because I am creating a deque of pointers to an abstract class, so it won't let me instantiate the class. (This is all so that I can take advantage of polymorphism, and call functions on a set of similar objects without worrying what type of object I'm dealing with).
So, I suppose my question is: what is the correct way to create that deque of pointers to the abstract class? I don't seem to be barking up the right tree currently.
View 4 Replies
View Related
Dec 11, 2009
I'm just learning to use Eclipse (have previously been a vim+make developer). I created the standard Hello World project following the tutorial. The program compiles fine, but if I build it again without cleaning the project, make aborts with a glibc double free message (pasted below). The same thing happens if I run make in the Debug directory outside eclipse. I don't know make well enough to figure out what the problem is, and to my mind Eclipse shouldn't be generating a buggy makefile anyway.
I've attached a tarfile of the project directory. Download the file and the following sequence of commands should show you the problem:
tar xvzf HelloWorld.tar.gz && cd HelloWorld/Debug && make && make
Also, if you think it would be worthwhile submitting a bugreport to the Fedora Eclipse dev team, let me know where I can do that and I'll be happy to.
Error messages:
11:07:34 [michael@tablet Debug]$ make
*** glibc detected *** make: double free or corruption (fasttop): 0x0000000001fd5780 ***
= Backtrace: =
/lib64/libc.so.6[0x3b03e75a96]
make[0x411f46]
make[0x411fb2]
make[0x411feb]
make[0x40771e]
make[0x411177]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x3b03e1ea2d]
make[0x402429]
= Memory map: =
00400000-00428000 r-xp 00000000 fd:04 1517952 /usr/bin/make
00628000-0062a000 rw-p 00028000 fd:04 1517952 /usr/bin/make
01fc0000-01fe1000 rw-p 00000000 00:00 0 [heap]
3b03a00000-3b03a1f000 r-xp 00000000 fd:00 81929 /lib64/ld-2.10.1.so
3b03c1e000-3b03c1f000 r--p 0001e000 fd:00 81929 /lib64/ld-2.10.1.so
3b03c1f000-3b03c20000 rw-p 0001f000 fd:00 81929 /lib64/ld-2.10.1.so
3b03e00000-3b03f64000 r-xp 00000000 fd:00 81933 /lib64/libc-2.10.1.so
3b03f64000-3b04164000 ---p 00164000 fd:00 81933 /lib64/libc-2.10.1.so
3b04164000-3b04168000 r--p 00164000 fd:00 81933 /lib64/libc-2.10.1.so
3b04168000-3b04169000 rw-p 00168000 fd:00 81933 /lib64/libc-2.10.1.so
3b04169000-3b0416e000 rw-p 00000000 00:00 0
3b08e00000-3b08e19000 r-xp 00000000 fd:00 81991 /lib64/libgcc_s-4.4.1-20090729.so.1
3b08e19000-3b09019000 ---p 00019000 fd:00 81991 /lib64/libgcc_s-4.4.1-20090729.so.1
3b09019000-3b0901a000 rw-p 00019000 fd:00 81991 /lib64/libgcc_s-4.4.1-20090729.so.1
7f6032b9d000-7f6037c70000 r--p 00000000 fd:04 1155417 /usr/lib32/locale/locale-archive
7f6037c70000-7f6037c74000 rw-p 00000000 00:00 0
7fffa6c19000-7fffa6c2e000 rw-p 00000000 00:00 0 [stack]
7fffa6c44000-7fffa6c45000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted
View 1 Replies
View Related
Jun 11, 2010
I want to create a "Shared Memory" in linux, then create multiple "Shared Objects" that can access to a Table for example; And one of them can write something into the Table and the other can access and read it, so that these operations can be handled by programmer! I'm using Ubuntu 9.04 and I've set it's runlevel at 3 (I have commandline environment now!) I've searched the Internet so much, but couldn't find a good sample code for this! I have no experience about it and need your help to introduce me a sample code about it and advise me how to compile and use it with "GCC"?!
View 6 Replies
View Related
Mar 17, 2011
I just maked an ext4 partition by the help of gparted. Ubuntu is my only OS no dual boot. Using Ubuntu Maverick. The problem is partition must be open as root to do any work else it wont even allow me to open file,create folder,cut copy paste or anything.
View 9 Replies
View Related
Sep 4, 2010
Code: //Author: Donald Farkas
//Created: Sep/4/2010
#include <iostream>
[code].....
View 6 Replies
View Related
Aug 4, 2010
Kernel 2.6.21.5, GNU (Slackware 12.0).
Bash 3.1.17.
I want to search an entire subtree of /, in the file system, for all files, with extension html, created on the hard disk. In addition, these have to be the last five created. I think I could split the problem into two parts: (a) Forget about the last condition. Then this is a job for the find command. (b) Sort the output of find using the date as the key, then use 'head' to print the desired output. But even two such simple steps are enough to justify the writing of a shell script. And here lies my weakness.
My script writing knowledge is rudimentary. What's the final purpose? Well, I lately saved four or five LQ pages onto disk containing information I consider valuable to me. But I don't exactly remember where on the disk. Then: either the problem posed is really of a very simple nature or it is not, in the latter case a script being mandatory. One of the algorithm drawbacks (the one described above) is that find may be running a great deal of time. My machine resources (RAM and CPU speed are low) are scarce and there possible are a large number of HTML files on the disk.
View 8 Replies
View Related
Feb 19, 2010
I have created a file with a pre-defined size as follows:
Code:
#define FILEPATH "testfile"
#define FILESIZE 16
[code]...
View 5 Replies
View Related
Aug 30, 2010
The goal is to auto-update a webpage that contains links to network devices. These devices are all set to DHCP, and their hostnames are not guaranteed to stay the same, so static IPs or accessing via hostname is NOT an option.
Process: Run a script every hour or so to query devices on the local network to generate a list of responding devices by MAC address and what their current IP is (results.lst). Using a "static" MAC address list file "printers.db" as the database search "results.lst" to find specific MAC addresses. When a match is found, grab the IP from "results.lst" and update "index.html" with the new IP address. No comparison needs to be done between "results.lst" IP and "index.html" IP as I just want to overwrite whatever is there.
Here is what I have so far (using dummy data):
PRINTERS.DBProduct Mac Address
Printer1 00:00:00:00:00:11
Printer2 00:00:00:00:11:11
Printer3 00:00:00:11:11:11
Printer4 00:00:11:11:11:11
Printer5 00:11:11:11:11:11
Printer6 11:11:11:11:11:11
[Code]....
View 10 Replies
View Related
Dec 17, 2008
I have list of programs which I have created during the past few days, all the programs are attached in txt files, and if anyone can do favor, and double check if they work, and what changes I can make to make it look different, or to improve it.
View 9 Replies
View Related
Jan 7, 2011
I created a script to flush my sendmail to another mailserver. Because it takes some time I want to give some simple feedback using a rotating bar.
Code:
I'm convinced this can be done much nicer with 'awk' and printf, but somehow awk makes me dazzle..
View 1 Replies
View Related
Apr 23, 2010
My program need to monitor the foler to know which file under the folder is being opened/created for writing. I add the folder into watch list using inotify_add_watch, when a file -- say 'AA' -- is created, I'll get the event through read api call. But the inotify_event only have file name 'AA' and a event mask. these parameters can't help me to know how the 'AA' is created/openned. So I have to scan the /proc folder to get to know how is 'AA' created/openned. I don't think this is a efficient way, especially if there are lots of files are openned/created in a short time span.
View 3 Replies
View Related
Mar 9, 2010
[URL] Essentially, this module can be fine-tuned to the user's liking, using four integers instead of a boolean. By allowing for the red, green, blue, and alpha values to be fine-tuned, the user can control how transparent or opaque their desktop is. And how is this possible? C++ instead of C. How do you guys think of being able to customize RGBA?
View 14 Replies
View Related
Jan 12, 2009
I have an awk program that finds all files of a specific filename and deletes them from selected subdirectories. There is logic in the awk to avoid certain subdirectories, and this is initialized via a parameter in the beginning statement of the awk. The parameter should have all of the subdirectory names at the top level. This varies from time to time, so I cannot hard-code the value.I'm having a problem initializing the awk parameter using sed. I'm setting a variable (named subdir) using an "ls" command piped to "xargs". I'm then trying to substitute that value into the awk using the sed command.
View 3 Replies
View Related